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


Python HTTP.response方法代碼示例

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


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

示例1: test_http_get_response_check_404

# 需要導入模塊: from Naked.toolshed.network import HTTP [as 別名]
# 或者: from Naked.toolshed.network.HTTP import response [as 別名]
 def test_http_get_response_check_404(self):
     """Confirm that the response object contains a 404 status code when authentication required"""
     http = HTTP('http://httpbin.org/status/404')
     http.get()
     self.assertEqual(http.res.status_code, 404)
     response = http.response()
     self.assertEqual(response.status_code, 404)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:9,代碼來源:test_NETWORK.py

示例2: test_http_get_response_check_301

# 需要導入模塊: from Naked.toolshed.network import HTTP [as 別名]
# 或者: from Naked.toolshed.network.HTTP import response [as 別名]
 def test_http_get_response_check_301(self):
     """Confirm that the reponse object contains 301 status code when do not follow redirects"""
     http = HTTP('http://httpbin.org/status/301')
     http.get(False) # do not follow redirects
     self.assertEqual(http.res.status_code, 301)
     response = http.response()
     self.assertEqual(response.status_code, 301)
開發者ID:chrisidefix,項目名稱:naked,代碼行數:9,代碼來源:test_NETWORK.py

示例3: test_http_get_response_check_200

# 需要導入模塊: from Naked.toolshed.network import HTTP [as 別名]
# 或者: from Naked.toolshed.network.HTTP import response [as 別名]
 def test_http_get_response_check_200(self):
     """Confirm that the response object contains 200 status code"""
     http = HTTP('http://httpbin.org/status/200')
     http.get()
     self.assertEqual(http.res.status_code, 200) # test the response object attribute
     response = http.response()
     self.assertEqual(response.status_code, 200) # test the returned object from the response() method
開發者ID:chrisidefix,項目名稱:naked,代碼行數:9,代碼來源:test_NETWORK.py

示例4: post_response

# 需要導入模塊: from Naked.toolshed.network import HTTP [as 別名]
# 或者: from Naked.toolshed.network.HTTP import response [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
開發者ID:chrissimpkins,項目名稱:status,代碼行數:28,代碼來源:http_request.py

示例5: test_http_get_response_method_return_value_missingsite

# 需要導入模塊: from Naked.toolshed.network import HTTP [as 別名]
# 或者: from Naked.toolshed.network.HTTP import response [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())
開發者ID:chrisidefix,項目名稱:naked,代碼行數:7,代碼來源:test_NETWORK.py

示例6: test_http_post_ssl

# 需要導入模塊: from Naked.toolshed.network import HTTP [as 別名]
# 或者: from Naked.toolshed.network.HTTP import response [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')
開發者ID:chrisidefix,項目名稱:naked,代碼行數:8,代碼來源:test_NETWORK.py


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