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 | 5 |
6 class RequestHeaders(object): | 6 class RequestHeaders(object): |
7 '''A custom dictionary impementation for headers which ignores the case | 7 '''A custom dictionary impementation for headers which ignores the case |
8 of requests, since different HTTP libraries seem to mangle them. | 8 of requests, since different HTTP libraries seem to mangle them. |
9 ''' | 9 ''' |
10 def __init__(self, dict_): | 10 def __init__(self, dict_): |
(...skipping 15 matching lines...) Expand all Loading... |
26 class Request(object): | 26 class Request(object): |
27 '''Request data. | 27 '''Request data. |
28 ''' | 28 ''' |
29 def __init__(self, path, host, headers, arguments={}): | 29 def __init__(self, path, host, headers, arguments={}): |
30 self.path = path.lstrip('/') | 30 self.path = path.lstrip('/') |
31 self.host = host.rstrip('/') | 31 self.host = host.rstrip('/') |
32 self.headers = RequestHeaders(headers) | 32 self.headers = RequestHeaders(headers) |
33 self.arguments = arguments | 33 self.arguments = arguments |
34 | 34 |
35 @staticmethod | 35 @staticmethod |
36 def ForTest(path, host=None, headers=None): | 36 def ForTest(path, host=None, headers=None, arguments=None): |
37 return Request(path, host or 'http://developer.chrome.com', headers or {}) | 37 return Request(path, |
| 38 host or 'http://developer.chrome.com', |
| 39 headers or {}, |
| 40 arguments or {}) |
38 | 41 |
39 def __repr__(self): | 42 def __repr__(self): |
40 return 'Request(path=%s, host=%s, headers=%s)' % ( | 43 return 'Request(path=%s, host=%s, headers=%s)' % ( |
41 self.path, self.host, self.headers) | 44 self.path, self.host, self.headers) |
42 | 45 |
43 def __str__(self): | 46 def __str__(self): |
44 return repr(self) | 47 return repr(self) |
45 | 48 |
46 class _ContentBuilder(object): | 49 class _ContentBuilder(object): |
47 '''Builds the response content. | 50 '''Builds the response content. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return repr(self) | 160 return repr(self) |
158 | 161 |
159 class Servlet(object): | 162 class Servlet(object): |
160 def __init__(self, request): | 163 def __init__(self, request): |
161 self._request = request | 164 self._request = request |
162 | 165 |
163 def Get(self): | 166 def Get(self): |
164 '''Returns a Response. | 167 '''Returns a Response. |
165 ''' | 168 ''' |
166 raise NotImplemented() | 169 raise NotImplemented() |
OLD | NEW |