我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用httplib.CannotSendHeader()。
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()
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