Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1591)

Side by Side Diff: chrome/common/extensions/docs/server2/servlet.py

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: epic rebase Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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('/')
11 self.headers = headers 11 self.headers = headers
12 12
13 @staticmethod 13 @staticmethod
14 def ForTest(path, host='http://developer.chrome.com', headers=None): 14 def ForTest(path, host='http://developer.chrome.com', headers=None):
15 return Request(path, host, headers or {}) 15 return Request(path, host, headers or {})
16 16
17 def __repr__(self): 17 def __repr__(self):
18 return 'Request(path=%s, host=%s, headers=%s entries)' % ( 18 return 'Request(path=%s, host=%s, headers=%s)' % (
19 self.path, self.host, len(self.headers.keys())) 19 self.path, self.host, self.headers)
20 20
21 def __str__(self): 21 def __str__(self):
22 return repr(self) 22 return repr(self)
23 23
24 class _ContentBuilder(object): 24 class _ContentBuilder(object):
25 '''Builds the response content. 25 '''Builds the response content.
26 ''' 26 '''
27 def __init__(self): 27 def __init__(self):
28 self._buf = [] 28 self._buf = []
29 29
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
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): 103 def GetRedirect(self):
104 if self.headers.get('Location') is None: 104 if self.headers.get('Location') is None:
105 return (None, None) 105 return (None, None)
106 return (self.headers.get('Location'), self.status == 301) 106 return (self.headers.get('Location'), self.status == 301)
107 107
108 def __eq__(self, other):
109 return (isinstance(other, self.__class__) and
110 str(other.content) == str(self.content) and
111 other.headers == self.headers and
112 other.status == self.status)
113
114 def __ne__(self, other):
115 return not (self == other)
116
108 def __repr__(self): 117 def __repr__(self):
109 return 'Response(content=%s bytes, status=%s, headers=%s entries)' % ( 118 return 'Response(content=%s bytes, status=%s, headers=%s)' % (
110 len(self.content), self.status, len(self.headers.keys())) 119 len(self.content), self.status, self.headers)
111 120
112 def __str__(self): 121 def __str__(self):
113 return repr(self) 122 return repr(self)
114 123
115 class Servlet(object): 124 class Servlet(object):
116 def __init__(self, request): 125 def __init__(self, request):
117 self._request = request 126 self._request = request
118 127
119 def Get(self): 128 def Get(self):
120 '''Returns a Response. 129 '''Returns a Response.
121 ''' 130 '''
122 raise NotImplemented() 131 raise NotImplemented()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/server_instance.py ('k') | chrome/common/extensions/docs/server2/sidenav_data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698