OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 class Request(object): | 5 class Request(object): |
6 '''Request data. | 6 '''Request data. |
7 ''' | 7 ''' |
8 def __init__(self, path, headers): | 8 def __init__(self, path, headers=None): |
9 self.path = path | 9 self.path = path.lstrip('/') |
| 10 if headers is None: |
| 11 headers = {} |
10 self.headers = headers | 12 self.headers = headers |
11 | 13 |
12 class _ContentBuilder(object): | 14 class _ContentBuilder(object): |
13 '''Builds the response content. | 15 '''Builds the response content. |
14 ''' | 16 ''' |
15 def __init__(self): | 17 def __init__(self): |
16 self._buf = [] | 18 self._buf = [] |
17 | 19 |
18 def Append(self, content): | 20 def Append(self, content): |
19 if isinstance(content, unicode): | 21 if isinstance(content, unicode): |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 len(self.content), self.status, len(self.headers.keys())) | 97 len(self.content), self.status, len(self.headers.keys())) |
96 | 98 |
97 class Servlet(object): | 99 class Servlet(object): |
98 def __init__(self, request): | 100 def __init__(self, request): |
99 self._request = request | 101 self._request = request |
100 | 102 |
101 def Get(self): | 103 def Get(self): |
102 '''Returns a Response. | 104 '''Returns a Response. |
103 ''' | 105 ''' |
104 raise NotImplemented() | 106 raise NotImplemented() |
OLD | NEW |