| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 class Request(object): | 26 class Request(object): |
| 27 '''Request data. | 27 '''Request data. |
| 28 ''' | 28 ''' |
| 29 def __init__(self, path, host, headers): | 29 def __init__(self, path, host, headers): |
| 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 | 33 |
| 34 @staticmethod | 34 @staticmethod |
| 35 def ForTest(path, host='http://developer.chrome.com', headers=None): | 35 def ForTest(path, host=None, headers=None): |
| 36 return Request(path, host, headers or {}) | 36 return Request(path, host or 'http://developer.chrome.com', headers or {}) |
| 37 | 37 |
| 38 def __repr__(self): | 38 def __repr__(self): |
| 39 return 'Request(path=%s, host=%s, headers=%s)' % ( | 39 return 'Request(path=%s, host=%s, headers=%s)' % ( |
| 40 self.path, self.host, self.headers) | 40 self.path, self.host, self.headers) |
| 41 | 41 |
| 42 def __str__(self): | 42 def __str__(self): |
| 43 return repr(self) | 43 return repr(self) |
| 44 | 44 |
| 45 class _ContentBuilder(object): | 45 class _ContentBuilder(object): |
| 46 '''Builds the response content. | 46 '''Builds the response content. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 return repr(self) | 150 return repr(self) |
| 151 | 151 |
| 152 class Servlet(object): | 152 class Servlet(object): |
| 153 def __init__(self, request): | 153 def __init__(self, request): |
| 154 self._request = request | 154 self._request = request |
| 155 | 155 |
| 156 def Get(self): | 156 def Get(self): |
| 157 '''Returns a Response. | 157 '''Returns a Response. |
| 158 ''' | 158 ''' |
| 159 raise NotImplemented() | 159 raise NotImplemented() |
| OLD | NEW |