| 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, host, headers): | 8 def __init__(self, path, host, headers): |
| 9 self.path = path.lstrip('/') | 9 self.path = path.lstrip('/') |
| 10 self.host = host.rstrip('/') | 10 self.host = host.rstrip('/') |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 self.headers[key] = value | 93 self.headers[key] = value |
| 94 | 94 |
| 95 def AddHeaders(self, headers): | 95 def AddHeaders(self, headers): |
| 96 '''Adds several headers to the response. | 96 '''Adds several headers to the response. |
| 97 ''' | 97 ''' |
| 98 self.headers.update(headers) | 98 self.headers.update(headers) |
| 99 | 99 |
| 100 def SetStatus(self, status): | 100 def SetStatus(self, status): |
| 101 self.status = status | 101 self.status = status |
| 102 | 102 |
| 103 def GetRedirect(self): |
| 104 if self.headers.get('Location') is None: |
| 105 return (None, None) |
| 106 return (self.headers.get('Location'), self.status == 301) |
| 107 |
| 103 def __repr__(self): | 108 def __repr__(self): |
| 104 return 'Response(content=%s bytes, status=%s, headers=%s entries)' % ( | 109 return 'Response(content=%s bytes, status=%s, headers=%s entries)' % ( |
| 105 len(self.content), self.status, len(self.headers.keys())) | 110 len(self.content), self.status, len(self.headers.keys())) |
| 106 | 111 |
| 107 def __str__(self): | 112 def __str__(self): |
| 108 return repr(self) | 113 return repr(self) |
| 109 | 114 |
| 110 class Servlet(object): | 115 class Servlet(object): |
| 111 def __init__(self, request): | 116 def __init__(self, request): |
| 112 self._request = request | 117 self._request = request |
| 113 | 118 |
| 114 def Get(self): | 119 def Get(self): |
| 115 '''Returns a Response. | 120 '''Returns a Response. |
| 116 ''' | 121 ''' |
| 117 raise NotImplemented() | 122 raise NotImplemented() |
| OLD | NEW |