本文整理汇总了Python中Naked.toolshed.network.HTTP.post方法的典型用法代码示例。如果您正苦于以下问题:Python HTTP.post方法的具体用法?Python HTTP.post怎么用?Python HTTP.post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Naked.toolshed.network.HTTP
的用法示例。
在下文中一共展示了HTTP.post方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_response
# 需要导入模块: from Naked.toolshed.network import HTTP [as 别名]
# 或者: from Naked.toolshed.network.HTTP import post [as 别名]
def post_response(self):
try:
the_url = prepare_url(self.url)
http = HTTP(the_url)
http.post()
resp = http.response()
# confirm that a response was returned, abort if not
if resp == None and the_url.startswith('https://'):
stderr("Unable to connect to the requested URL. This can happen if the secure HTTP protocol is not supported at the requested URL.")
sys.exit(1)
elif resp == None:
stderr("Unable to connect to the requested URL. Please confirm your URL and try again.")
sys.exit(1)
if len(resp.history) > 0:
count = len(resp.history)
for i in range(count):
print(str(resp.history[i].status_code) + " : " + str(resp.history[i].url))
print(str(http.res.status_code) + " : " + the_url)
exit_success()
except ConnectionError as ce:
error_string = "Unable to connect to the URL, " + self.url
stderr(error_string, 1)
except Exception as e:
raise e
示例2: test_http_post_type
# 需要导入模块: from Naked.toolshed.network import HTTP [as 别名]
# 或者: from Naked.toolshed.network.HTTP import post [as 别名]
def test_http_post_type(self):
"""Test the HTTP POST request return value type"""
http = HTTP("https://raw.github.com/chrissimpkins/six-four/master/LICENSE")
http_text = http.post()
if state.py2:
self.assertEqual(type(u"test string"), type(http_text))
else:
self.assertEqual(type(str("test string")), type(http_text))
示例3: test_http_post_response_status_200_ssl
# 需要导入模块: from Naked.toolshed.network import HTTP [as 别名]
# 或者: from Naked.toolshed.network.HTTP import post [as 别名]
def test_http_post_response_status_200_ssl(self):
"""Test that the status code 200 is appropriately detected after a SSL POST request"""
http = HTTP("https://httpbin.org/post")
http.post()
self.assertEqual(http.res.status_code, 200)
示例4: test_http_get_response_method_return_value_missingsite
# 需要导入模块: from Naked.toolshed.network import HTTP [as 别名]
# 或者: from Naked.toolshed.network.HTTP import post [as 别名]
def test_http_get_response_method_return_value_missingsite(self):
"""Test the return type from response() method when non-existent site is requested"""
http = HTTP('http://www.abogussitename.com')
http.post()
self.assertEqual(None, http.response())
示例5: test_http_get_response_content_object_missingsite
# 需要导入模块: from Naked.toolshed.network import HTTP [as 别名]
# 或者: from Naked.toolshed.network.HTTP import post [as 别名]
def test_http_get_response_content_object_missingsite(self):
"""Test the contents of the response object returned by requests when site is non-existent"""
http = HTTP('http://www.abogussitename.com')
http.post()
with self.assertRaises(AttributeError):
http.res.content # confirm that attempt to access the content attribute of res raises Exception when no site
示例6: test_http_POST_response_object_missingsite
# 需要导入模块: from Naked.toolshed.network import HTTP [as 别名]
# 或者: from Naked.toolshed.network.HTTP import post [as 别名]
def test_http_POST_response_object_missingsite(self):
"""Test the POST response object returned by requests when site is non-existent"""
http = HTTP('http://www.abogussitename.com')
http.post()
self.assertEqual(None, http.res)
示例7: test_http_post_contents_response_missingsite
# 需要导入模块: from Naked.toolshed.network import HTTP [as 别名]
# 或者: from Naked.toolshed.network.HTTP import post [as 别名]
def test_http_post_contents_response_missingsite(self):
"""Test the contents of the POST request response when the site is non-existent"""
http = HTTP('http://www.abogussitename.com')
self.assertEqual(False, http.post()) # returns False if requests ConnectionError
示例8: test_http_post_ssl
# 需要导入模块: from Naked.toolshed.network import HTTP [as 别名]
# 或者: from Naked.toolshed.network.HTTP import post [as 别名]
def test_http_post_ssl(self):
"""Test HTTP POST request content data"""
http = HTTP("https://httpbin.org/post")
http_text = http.post()
response = http.response()
self.assertEqual(response.url, 'https://httpbin.org/post')