Esempio n. 1
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()
Esempio n. 2
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()
Esempio n. 3
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()
Esempio n. 4
0
    def test_012_ssl_server(self):
        from eventlib 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.assertEqual(result, 'abc')
Esempio n. 5
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))
Esempio n. 6
0
 def test_post(self):
     data = 'qunge'
     self.assertEqual(httpc.post(self.base_url() + '', data=data),
                       data)