From: Ben Darnell Date: Fri, 9 May 2014 00:54:42 +0000 (-0400) Subject: Merge pull request #1042 from moijes12/fix1033_2 X-Git-Tag: v4.0.0b1~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33a84e01744740bc64f4098565d5fb58725540cb;p=thirdparty%2Ftornado.git Merge pull request #1042 from moijes12/fix1033_2 Changed _on_close method tornado/simple_httpclient.py to raise the error instead of raising an HTTPError --- 33a84e01744740bc64f4098565d5fb58725540cb diff --cc tornado/simple_httpclient.py index 511141e1d,d5b980611..d35ff1def --- a/tornado/simple_httpclient.py +++ b/tornado/simple_httpclient.py @@@ -423,16 -371,25 +423,16 @@@ class _HTTPConnection(httputil.HTTPMess if self.final_callback is not None: message = "Connection closed" if self.stream.error: - message = str(self.stream.error) + raise self.stream.error raise HTTPError(599, message) - def _handle_1xx(self, code): - self.stream.read_until_regex(b"\r?\n\r?\n", self._on_headers) - - def _on_headers(self, data): - data = native_str(data.decode("latin1")) - first_line, _, header_data = data.partition("\n") - match = re.match("HTTP/1.[01] ([0-9]+) ([^\r]*)", first_line) - assert match - code = int(match.group(1)) - self.headers = HTTPHeaders.parse(header_data) - if 100 <= code < 200: - self._handle_1xx(code) + def headers_received(self, first_line, headers): + if self.request.expect_100_continue and first_line.code == 100: + self._write_body(False) return - else: - self.code = code - self.reason = match.group(2) + self.headers = headers + self.code = first_line.code + self.reason = first_line.reason if "Content-Length" in self.headers: if "," in self.headers["Content-Length"]: