當前位置: 首頁>>代碼示例>>Python>>正文


Python HttpClient.get方法代碼示例

本文整理匯總了Python中pulsar.apps.http.HttpClient.get方法的典型用法代碼示例。如果您正苦於以下問題:Python HttpClient.get方法的具體用法?Python HttpClient.get怎麽用?Python HttpClient.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pulsar.apps.http.HttpClient的用法示例。


在下文中一共展示了HttpClient.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_verify

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_verify(self):
     c = HttpClient()
     yield from self.async.assertRaises(SSLError, c.get, self.httpbin())
     response = yield from c.get(self.httpbin(), verify=False)
     self.assertEqual(response.status_code, 200)
     response = yield from c.get(self.httpbin(), verify=crt)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.request.verify, crt)
開發者ID:arhik,項目名稱:pulsar,代碼行數:10,代碼來源:tls.py

示例2: test_home

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_home(self):
     http = HttpClient()
     response = yield from http.get(self.url)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.headers['content-type'],
                      'text/html; charset=utf-8')
     cookie = response.cookies.get('luxtest')
     self.assertTrue(cookie)
     self.assertTrue(cookie.value)
     response = yield from http.get(self.url)
     cookie2 = response.cookies.get('luxtest')
     self.assertFalse(cookie2)
開發者ID:SirZazu,項目名稱:lux,代碼行數:14,代碼來源:all.py

示例3: testBadRequests

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def testBadRequests(self):
     c = HttpClient()
     response = yield c.post(self.ws_uri)
     self.assertEqual(response.status_code, 405)
     #
     response = yield c.get(self.ws_uri,
                            headers=[('Sec-Websocket-Key', 'x')])
     self.assertEqual(response.status_code, 400)
     #
     response = yield c.get(self.ws_uri,
                            headers=[('Sec-Websocket-Key', 'bla')])
     self.assertEqual(response.status_code, 400)
     #
     response = yield c.get(self.ws_uri,
                            headers=[('Sec-Websocket-version', 'xxx')])
     self.assertEqual(response.status_code, 400)
開發者ID:LoganTK,項目名稱:pulsar,代碼行數:18,代碼來源:tests.py

示例4: test_graph

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_graph(self):
     c = HttpClient()
     handler = Echo(c._loop)
     ws = yield c.get(self.ws_uri, websocket_handler=handler)
     self.assertEqual(ws.event('post_request').fired(), 0)
     message = yield handler.get()
     self.assertTrue(message)
開發者ID:axisofentropy,項目名稱:pulsar,代碼行數:9,代碼來源:tests.py

示例5: test_login

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_login(self):
     http = HttpClient()
     url = self.url + self.app.config['LOGIN_URL']
     response = yield from http.get(url)
     cookie = response.cookies.get('luxtest')
     self.assertTrue(cookie)
     self.assertEqual(response.status_code, 200)
     doc = self.bs(response)
     token = self.authenticity_token(doc)
     self.assertEqual(len(token), 1)
     # try to login
     data = {'username': 'pippo', 'password': 'pluto'}
     response2 = yield from http.post(url, data=data)
     self.assertEqual(response2.status_code, 403)
     #
     # Add csrf token
     data.update(token)
     response2 = yield from http.post(url, data=data)
     self.assertEqual(response2.status_code, 200)
     cookie2 = response2.cookies.get('luxtest')
     self.assertTrue(cookie2)
     self.assertNotEqual(cookie2.value, cookie.value)
     self.assertEqual(response2.headers['content-type'],
                      'application/json; charset=utf-8')
     data = response2.json()
     self.assertTrue('redirect' in data)
     self.assertEqual(data['success'], True)
     #
     # Login again should cause MethodNotAllowed
     response3 = yield from http.post(url, data=data)
     self.assertEqual(response3.status_code, 405)
開發者ID:SirZazu,項目名稱:lux,代碼行數:33,代碼來源:all.py

示例6: test_pong

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_pong(self):
     c = HttpClient()
     handler = Echo()
     ws = yield c.get(self.ws_echo, websocket_handler=handler).on_headers
     #
     ws.ping('TESTING CLIENT PING')
     message = yield handler.get()
     self.assertEqual(message, 'PONG: TESTING CLIENT PING')
開發者ID:xmnlab,項目名稱:minilab,代碼行數:10,代碼來源:tests.py

示例7: test_ping

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_ping(self):
     c = HttpClient()
     handler = Echo()
     ws = yield c.get(self.ws_echo, websocket_handler=handler).on_headers
     #
     # ASK THE SERVER TO SEND A PING FRAME
     ws.write('send ping TESTING PING')
     message = yield handler.get()
     self.assertEqual(message, 'PING: TESTING PING')
開發者ID:xmnlab,項目名稱:minilab,代碼行數:11,代碼來源:tests.py

示例8: test_dodgy_on_header_event

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_dodgy_on_header_event(self):
     client = HttpClient()
     hook = partial(dodgyhook, self)
     response = client.get(self.httpbin(), on_headers=hook)
     try:
         yield response.on_finished
     except ValueError:
         pass
     self.assertTrue(response.headers)
     self.assertIsInstance(response.on_headers.result, Failure)
開發者ID:elimisteve,項目名稱:pulsar,代碼行數:12,代碼來源:client.py

示例9: test_close

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_close(self):
     c = HttpClient()
     handler = Echo()
     ws = yield c.get(self.ws_echo, websocket_handler=handler)
     self.assertEqual(ws.event('post_request').fired(), 0)
     ws.write('send close 1001')
     message = yield handler.get()
     self.assertEqual(message, 'CLOSE')
     self.assertTrue(ws.close_reason)
     self.assertEqual(ws.close_reason[0], 1001)
     self.assertTrue(ws._connection.closed)
開發者ID:LoganTK,項目名稱:pulsar,代碼行數:13,代碼來源:tests.py

示例10: test_close_sync

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_close_sync(self):
     loop = new_event_loop()
     c = HttpClient(loop=loop)
     handler = Echo(loop)
     ws = c.get(self.ws_echo, websocket_handler=handler)
     self.assertEqual(ws.event('post_request').fired(), 0)
     self.assertEqual(ws._loop, loop)
     self.assertFalse(ws._loop.is_running())
     ws.write('send close 1001')
     message = ws._loop.run_until_complete(handler.get())
     self.assertEqual(message, 'CLOSE')
     self.assertTrue(ws.close_reason)
     self.assertEqual(ws.close_reason[0], 1001)
     self.assertTrue(ws._connection.closed)
開發者ID:LoganTK,項目名稱:pulsar,代碼行數:16,代碼來源:tests.py

示例11: test_upgrade

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_upgrade(self):
     c = HttpClient()
     handler = Echo()
     ws = yield c.get(self.ws_echo, websocket_handler=handler).on_headers
     response = ws.handshake
     self.assertEqual(response.status_code, 101)
     self.assertEqual(response.headers['upgrade'], 'websocket')
     self.assertEqual(ws.connection, response.connection)
     self.assertEqual(ws.handler, handler)
     #
     # on_finished
     self.assertFalse(response.on_finished.done())
     self.assertFalse(ws.on_finished.done())
     # Send a message to the websocket
     ws.write('Hi there!')
     message = yield handler.get()
     self.assertEqual(message, 'Hi there!')
開發者ID:xmnlab,項目名稱:minilab,代碼行數:19,代碼來源:tests.py

示例12: media_libraries

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
def media_libraries():
    global _media_libraries
    if _media_libraries is None:
        if os.path.isfile('libs.json'):     # pragma    nocover
            with open('libs.json') as f:
                data = f.read()
            _media_libraries = json.loads(data)
        else:
            from pulsar import new_event_loop
            from pulsar.apps.http import HttpClient
            http = HttpClient(loop=new_event_loop())
            try:
                response = http.get(_libs_url)
                _media_libraries = response.json()
            except Exception:   # pragma    nocover
                http.logger.error('Could not import media library',
                                  exc_info=True)
                _media_libraries = {'libs': {}, 'deps': {}}
    return _media_libraries
開發者ID:axisofentropy,項目名稱:pulsar,代碼行數:21,代碼來源:content.py

示例13: test_home

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_home(self):
     c = HttpClient()
     response = yield c.get(self.uri)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.headers['content-type'],
                      'text/html; charset=utf-8')
開發者ID:axisofentropy,項目名稱:pulsar,代碼行數:8,代碼來源:tests.py

示例14: test_404

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_404(self):
     http = HttpClient()
     url = self.url + '/dkvshcvsdkchsdkc'
     response = yield from http.get(url)
     self.assertEqual(response.status_code, 404)
開發者ID:SirZazu,項目名稱:lux,代碼行數:7,代碼來源:all.py

示例15: test_reset_password

# 需要導入模塊: from pulsar.apps.http import HttpClient [as 別名]
# 或者: from pulsar.apps.http.HttpClient import get [as 別名]
 def test_reset_password(self):
     http = HttpClient()
     url = self.url + self.app.config['RESET_PASSWORD_URL']
     response = yield from http.get(url)
     self.assertEqual(response.status_code, 200)
開發者ID:SirZazu,項目名稱:lux,代碼行數:7,代碼來源:all.py


注:本文中的pulsar.apps.http.HttpClient.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。