Example #1
0
 def test_post(self):
     data = 'hello world'
     try:
         response = httpc.post(self.base_url() + 'hello', data=data)
         self.assert_(False)
     except httpc.SeeOther, err:
         response = err.retry()
Example #2
0
 def test_post(self):
     data = 'hello world'
     try:
         response = httpc.post(self.base_url() + 'hello', data=data)
         self.assert_(False)
     except httpc.TemporaryRedirect, err:
         response = err.retry()
Example #3
0
 def test_post(self):
     data = 'hello world'
     try:
         response = httpc.post(self.base_url() + 'hello', data=data)
         self.assert_(False)
     except httpc.TemporaryRedirect, err:
         response = err.retry()
Example #4
0
 def test_post(self):
     data = 'qunge'
     try:
         response = httpc.post(self.base_url() + '', data=data)
         self.assert_(False)
     except httpc.MovedPermanently, err:
         response = err.retry()
Example #5
0
 def send(self, url, data=''):
     # Catch non-successful HTTP requests and treat them as if they were.
     try:
         result = httpc.post(url, data=data,
             content_type='application/json; charset=utf-8')
     except httpc.ConnectionError, exc:
         result = exc.params.response_body
Example #6
0
 def test_post(self):
     data = 'hello world'
     try:
         response = httpc.post(self.base_url() + 'hello', data=data)
         self.assert_(False)
     except httpc.SeeOther, err:
         response = err.retry()
Example #7
0
 def test_post(self):
     data = 'qunge'
     try:
         response = httpc.post(self.base_url() + '', data=data)
         self.assert_(False)
     except httpc.MovedPermanently, err:
         response = err.retry()
Example #8
0
 def send(self, url, data=''):
     # Catch non-successful HTTP requests and treat them as if they were.
     try:
         result = httpc.post(url,
                             data=data,
                             content_type='application/json; charset=utf-8')
     except httpc.ConnectionError, exc:
         result = exc.params.response_body
Example #9
0
    def test_012_ssl_server(self):
        from eventlet import httpc
        def wsgi_app(environ, start_response):
            start_response('200 OK', {})
            return [environ['wsgi.input'].read()]

        certificate_file = os.path.join(os.path.dirname(__file__), 'test_server.crt')
        private_key_file = os.path.join(os.path.dirname(__file__), 'test_server.key')

        sock = api.ssl_listener(('', 4201), certificate_file, private_key_file)

        api.spawn(wsgi.server, sock, wsgi_app)

        result = httpc.post("https://localhost:4201/foo", "abc")
        self.assertEquals(result, 'abc')
Example #10
0
    def test_012_ssl_server(self):
        from eventlet import httpc

        def wsgi_app(environ, start_response):
            start_response('200 OK', {})
            return [environ['wsgi.input'].read()]

        certificate_file = os.path.join(os.path.dirname(__file__),
                                        'test_server.crt')
        private_key_file = os.path.join(os.path.dirname(__file__),
                                        'test_server.key')

        sock = api.ssl_listener(('', 4201), certificate_file, private_key_file)

        api.spawn(wsgi.server, sock, wsgi_app)

        result = httpc.post("https://localhost:4201/foo", "abc")
        self.assertEquals(result, 'abc')
Example #11
0
 def test_post(self):
     # Simply ensure that a 504 status code results in a
     # GatewayTimeout.  Don't bother retrying.
     data = 'hello world'
     self.assertRaises(httpc.GatewayTimeout,
                       lambda: httpc.post(self.base_url(), data=data))
Example #12
0
 def test_post(self):
     data = 'qunge'
     self.assertEquals(httpc.post(self.base_url() + '', data=data), data)
Example #13
0
 def test_post(self):
     # Simply ensure that a 504 status code results in a
     # GatewayTimeout.  Don't bother retrying.
     data = 'hello world'
     self.assertRaises(httpc.GatewayTimeout,
                       lambda: httpc.post(self.base_url(), data=data))
Example #14
0
 def test_post(self):
     data = 'qunge'
     self.assertEquals(httpc.post(self.base_url() + '', data=data),
                       data)