当前位置: 首页>>代码示例>>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;未经允许,请勿转载。