コード例 #1
0
ファイル: http.py プロジェクト: rgcarrasqueira/python-slimta
 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)
コード例 #2
0
ファイル: http.py プロジェクト: rgcarrasqueira/python-slimta
 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)
コード例 #3
0
ファイル: http.py プロジェクト: sk1p/python-slimta
 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)
コード例 #4
0
 def test_get_connection(self):
     conn = get_connection('http://localhost')
     self.assertIsInstance(conn, HTTPConnection)
     conn = get_connection('https://localhost')
     self.assertIsInstance(conn, HTTPSConnection)
コード例 #5
0
 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)
コード例 #6
0
ファイル: http.py プロジェクト: dldorsey/python-slimta
 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
コード例 #7
0
ファイル: http.py プロジェクト: slimta/python-slimta
 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
コード例 #8
0
 def test_get_connection(self):
     conn = get_connection("http://localhost")
     self.assertIsInstance(conn, HTTPConnection)
     conn = get_connection("https://localhost")
     self.assertIsInstance(conn, HTTPSConnection)