def _handle_request(self, result, envelope): if not self.conn: self.conn = get_connection(self.url, self.relay.tls) with gevent.Timeout(self.relay.timeout): msg_headers, msg_body = envelope.flatten() headers = self._build_headers(envelope, msg_headers, msg_body) log.request(self.conn, "POST", self.url.path, headers) self.conn.putrequest("POST", self.url.path) for name, value in headers: self.conn.putheader(name, value) self.conn.endheaders(msg_headers) self.conn.send(msg_body) self._process_response(self.conn.getresponse(), result)
def _handle_request(self, result, envelope): if not self.conn: self.conn = get_connection(self.url, self.relay.tls) with gevent.Timeout(self.relay.timeout): msg_headers, msg_body = envelope.flatten() headers = self._build_headers(envelope, msg_headers, msg_body) log.request(self.conn, 'POST', self.url.path, headers) self.conn.putrequest('POST', self.url.path) for name, value in headers: self.conn.putheader(name, value) self.conn.endheaders(msg_headers) self.conn.send(msg_body) self._process_response(self.conn.getresponse(), result)
def _handle_request(self, result, envelope): method = self.relay.http_verb if not self.conn: self.conn = get_connection(self.url, self.relay.tls) with gevent.Timeout(self.relay.timeout): msg_headers, msg_body = envelope.flatten() headers = self._build_headers(envelope, msg_headers, msg_body) log.request(self.conn, method, self.url.path, headers) self.conn.putrequest(method, self.url.path) for name, value in headers: # https://www.python.org/dev/peps/pep-0333/#unicode-issues # value is sometime an int/float if isinstance(value, six.string_types): encoded_value = value.encode('iso-8859-1') else: encoded_value = value self.conn.putheader(name.encode('iso-8859-1'), encoded_value) self.conn.endheaders(msg_headers.encode('iso-8859-1')) self.conn.send(msg_body) self._process_response(self.conn.getresponse(), result)
def test_get_connection(self): conn = get_connection('http://localhost') self.assertIsInstance(conn, HTTPConnection) conn = get_connection('https://localhost') self.assertIsInstance(conn, HTTPSConnection)
def test_get_connection(self): conn = get_connection('http://localhost') assert_is_instance(conn, HTTPConnection) conn = get_connection('https://localhost') assert_is_instance(conn, HTTPSConnection)
def _new_conn(self): self.conn = get_connection(self.url, self.relay.tls) try: self.ehlo_as = self.relay.ehlo_as() except TypeError: self.ehlo_as = self.relay.ehlo_as
def _new_conn(self): self.conn = get_connection(self.url, self.relay.context) try: self.ehlo_as = self.relay.ehlo_as() except TypeError: self.ehlo_as = self.relay.ehlo_as
def test_get_connection(self): conn = get_connection("http://localhost") self.assertIsInstance(conn, HTTPConnection) conn = get_connection("https://localhost") self.assertIsInstance(conn, HTTPSConnection)