Exemple #1
0
    def process_request_line(self, line):
        assert self._response is None, "Already handling response"
        parts = http.parse_response_status(line)
        if parts is None:
            error = InvalidResponse("Wrong response format: %r", line)
            self._client_error(error)
            return
        protocol, status = parts
        self._response = self._requests.pop(0)
        self._response.protocol = protocol
        self._response.status = status
        self._response.makeConnection(self.transport)

        # HTTP 1.0 doesn't require Content-Length or Transfer-Encoding
        # response headers. It can simply start printing body after the
        # headers section and close the connection when it's done.
        # This requires special decoder which might be overwritten later
        # if one of the mentioned headers is received.
        # Moreover even though HTTP 1.1 defines that either Content-Length
        # or Transfer-Encoding is required, there are servers out there
        # which claim to speak HTTP 1.1 really speak HTTP 1.0.
        # One example I've seen is combination of:
        # < Server: Microsoft-IIS/6.0
        # < X-Powered-By: PHP/5.3.8
        # but its most probably not the only one. Therefore the only way
        # to support this is to assume content decoder and overwrite it later.
        self._setup_identity_decoding(length=None)
Exemple #2
0
 def process_request_line(self, line):
     assert self._response is None, "Already handling response"
     parts = http.parse_response_status(line)
     if parts is None:
         error = InvalidResponse("Wrong response format: %r", line)
         self._client_error(error)
         return
     protocol, status = parts
     self._response = Response()
     self._response.protocol = protocol
     self._response.stats = status