Beispiel #1
0
    def putheader(self, header, value):
        """Send a request header line to the server.

        For example: h.putheader('Accept', 'text/html')
        """
        if self.__state != _CS_REQ_STARTED:
            raise CannotSendHeader()

        self._headers[header] = value
Beispiel #2
0
    def endheaders(self, message_body=None, is_chunked=False):
        """Indicate that the last header line has been sent to the server.

		This method sends the request to the server.  The optional
		message_body argument can be used to pass a message body
		associated with the request.  The message body will be sent in
		the same packet as the message headers if it is string, otherwise it is
		sent as a separate packet.
		"""
        if self.__state == _CS_REQ_STARTED:
            self.__state = _CS_REQ_SENT
        else:
            raise CannotSendHeader()
        self._send_output(message_body, is_chunked=is_chunked)
Beispiel #3
0
    def endheaders(self):
        """Indicate that the last header line has been sent to the server."""

        if self.__state == _CS_REQ_STARTED:
            self.__state = _CS_REQ_SENT
        else:
            raise CannotSendHeader()

        for header in ('Host', 'Accept-Encoding'):
            if header in self._headers:
                str = '%s: %s' % (header, self._headers[header])
                self._output(str)
                del self._headers[header]

        for header, value in self._headers.items():
            str = '%s: %s' % (header, value)
            self._output(str)

        self._send_output()
Beispiel #4
0
 def endheaders(self, message_body=None):
     if self.__dict__['_HTTPConnection__state'] == _CS_REQ_STARTED:
         self.__dict__['_HTTPConnection__state'] = _CS_REQ_SENT
     else:
         raise CannotSendHeader()
     self._send_output(message_body)