Show More
@@ -133,10 +133,12 b' class _httprequesthandler(BaseHTTPServer' | |||||
133 | self.saved_headers = [] |
|
133 | self.saved_headers = [] | |
134 | self.sent_headers = False |
|
134 | self.sent_headers = False | |
135 | self.length = None |
|
135 | self.length = None | |
|
136 | self._chunked = None | |||
136 | for chunk in self.server.application(env, self._start_response): |
|
137 | for chunk in self.server.application(env, self._start_response): | |
137 | self._write(chunk) |
|
138 | self._write(chunk) | |
138 | if not self.sent_headers: |
|
139 | if not self.sent_headers: | |
139 | self.send_headers() |
|
140 | self.send_headers() | |
|
141 | self._done() | |||
140 |
|
142 | |||
141 | def send_headers(self): |
|
143 | def send_headers(self): | |
142 | if not self.saved_status: |
|
144 | if not self.saved_status: | |
@@ -145,15 +147,18 b' class _httprequesthandler(BaseHTTPServer' | |||||
145 | saved_status = self.saved_status.split(None, 1) |
|
147 | saved_status = self.saved_status.split(None, 1) | |
146 | saved_status[0] = int(saved_status[0]) |
|
148 | saved_status[0] = int(saved_status[0]) | |
147 | self.send_response(*saved_status) |
|
149 | self.send_response(*saved_status) | |
148 | should_close = True |
|
150 | self.length = None | |
|
151 | self._chunked = False | |||
149 | for h in self.saved_headers: |
|
152 | for h in self.saved_headers: | |
150 | self.send_header(*h) |
|
153 | self.send_header(*h) | |
151 | if h[0].lower() == 'content-length': |
|
154 | if h[0].lower() == 'content-length': | |
152 | should_close = False |
|
|||
153 | self.length = int(h[1]) |
|
155 | self.length = int(h[1]) | |
154 | # The value of the Connection header is a list of case-insensitive |
|
156 | if self.length is None: | |
155 | # tokens separated by commas and optional whitespace. |
|
157 | self._chunked = (not self.close_connection and | |
156 | if should_close: |
|
158 | self.request_version == "HTTP/1.1") | |
|
159 | if self._chunked: | |||
|
160 | self.send_header('Transfer-Encoding', 'chunked') | |||
|
161 | else: | |||
157 | self.send_header('Connection', 'close') |
|
162 | self.send_header('Connection', 'close') | |
158 | self.end_headers() |
|
163 | self.end_headers() | |
159 | self.sent_headers = True |
|
164 | self.sent_headers = True | |
@@ -177,9 +182,16 b' class _httprequesthandler(BaseHTTPServer' | |||||
177 | raise AssertionError("Content-length header sent, but more " |
|
182 | raise AssertionError("Content-length header sent, but more " | |
178 | "bytes than specified are being written.") |
|
183 | "bytes than specified are being written.") | |
179 | self.length = self.length - len(data) |
|
184 | self.length = self.length - len(data) | |
|
185 | elif self._chunked and data: | |||
|
186 | data = '%x\r\n%s\r\n' % (len(data), data) | |||
180 | self.wfile.write(data) |
|
187 | self.wfile.write(data) | |
181 | self.wfile.flush() |
|
188 | self.wfile.flush() | |
182 |
|
189 | |||
|
190 | def _done(self): | |||
|
191 | if self._chunked: | |||
|
192 | self.wfile.write('0\r\n\r\n') | |||
|
193 | self.wfile.flush() | |||
|
194 | ||||
183 | class _httprequesthandleropenssl(_httprequesthandler): |
|
195 | class _httprequesthandleropenssl(_httprequesthandler): | |
184 | """HTTPS handler based on pyOpenSSL""" |
|
196 | """HTTPS handler based on pyOpenSSL""" | |
185 |
|
197 |
@@ -124,7 +124,6 b' clone via pull' | |||||
124 | adding manifests |
|
124 | adding manifests | |
125 | adding file changes |
|
125 | adding file changes | |
126 | added 1 changesets with 4 changes to 4 files |
|
126 | added 1 changesets with 4 changes to 4 files | |
127 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
|||
128 | updating to branch default |
|
127 | updating to branch default | |
129 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
128 | 4 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
130 | $ hg verify -R copy-pull |
|
129 | $ hg verify -R copy-pull | |
@@ -152,7 +151,6 b' pull without cacert' | |||||
152 | adding manifests |
|
151 | adding manifests | |
153 | adding file changes |
|
152 | adding file changes | |
154 | added 1 changesets with 1 changes to 1 files |
|
153 | added 1 changesets with 1 changes to 1 files | |
155 | warning: localhost certificate with fingerprint 91:4f:1a:ff:87:24:9c:09:b6:85:9b:88:b1:90:6d:30:75:64:91:ca not verified (check hostfingerprints or web.cacerts config setting) |
|
|||
156 | changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=https://localhost:$HGPORT/ |
|
154 | changegroup hook: HG_NODE=5fed3813f7f5e1824344fdc9cf8f63bb662c292d HG_SOURCE=pull HG_URL=https://localhost:$HGPORT/ | |
157 | (run 'hg update' to get a working copy) |
|
155 | (run 'hg update' to get a working copy) | |
158 | $ cd .. |
|
156 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now