当前位置: 首页>>代码示例>>Python>>正文


Python HTTPResponse.should_close方法代码示例

本文整理汇总了Python中geventhttpclient.response.HTTPResponse.should_close方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPResponse.should_close方法的具体用法?Python HTTPResponse.should_close怎么用?Python HTTPResponse.should_close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在geventhttpclient.response.HTTPResponse的用法示例。


在下文中一共展示了HTTPResponse.should_close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_keep_alive_bodyless_10x_request_with_body

# 需要导入模块: from geventhttpclient.response import HTTPResponse [as 别名]
# 或者: from geventhttpclient.response.HTTPResponse import should_close [as 别名]
def test_keep_alive_bodyless_10x_request_with_body():
    response = HTTPResponse()
    response.feed("""HTTP/1.1 100 Continue\r\n\r\n""")
    assert response.should_keep_alive()

    response = HTTPResponse()
    response.feed("""HTTP/1.1 100 Continue\r\nTransfer-Encoding: identity\r\n\r\n""")
    assert response.should_keep_alive()
    assert response.should_close()
    response = HTTPResponse()
    response.feed("""HTTP/1.1 100 Continue\r\nTransfer-Encoding: chunked\r\n\r\n""")
    assert response.should_keep_alive()
    assert response.should_close()
开发者ID:handloomweaver,项目名称:geventhttpclient,代码行数:15,代码来源:test_keep_alive.py

示例2: test_incomplete_response

# 需要导入模块: from geventhttpclient.response import HTTPResponse [as 别名]
# 或者: from geventhttpclient.response.HTTPResponse import should_close [as 别名]
def test_incomplete_response():
    response = HTTPResponse()
    response.feed("""HTTP/1.1 200 Ok\r\nContent-Length:10\r\n\r\n1""")
    with pytest.raises(HTTPParseError):
        response.feed("")
    assert response.should_keep_alive()
    assert response.should_close()
开发者ID:handloomweaver,项目名称:geventhttpclient,代码行数:9,代码来源:test_parser.py

示例3: test_simple

# 需要导入模块: from geventhttpclient.response import HTTPResponse [as 别名]
# 或者: from geventhttpclient.response.HTTPResponse import should_close [as 别名]
def test_simple():
    response = HTTPResponse()
    response.feed("""HTTP/1.1 200 Ok\r\nContent-Length: 0\r\n\r\n""")
    assert response.headers_complete
    assert response.message_complete
    assert response.should_keep_alive()
    assert not response.should_close()
    assert response.status_code == 200
开发者ID:KLab,项目名称:geventhttpclient,代码行数:10,代码来源:test_keep_alive.py

示例4: test_close_connection_and_no_content_length

# 需要导入模块: from geventhttpclient.response import HTTPResponse [as 别名]
# 或者: from geventhttpclient.response.HTTPResponse import should_close [as 别名]
def test_close_connection_and_no_content_length():
    response = HTTPResponse()
    response.feed("HTTP/1.1 200 Ok\r\n"
                "Connection: close\r\n\r\n"
                "Hello World!")
    assert response._body_buffer == bytearray("Hello World!")
    assert not response.should_keep_alive()
    assert response.should_close()
开发者ID:KLab,项目名称:geventhttpclient,代码行数:10,代码来源:test_keep_alive.py

示例5: test_keep_alive_http_10

# 需要导入模块: from geventhttpclient.response import HTTPResponse [as 别名]
# 或者: from geventhttpclient.response.HTTPResponse import should_close [as 别名]
def test_keep_alive_http_10():
    response = HTTPResponse()
    response.feed("""HTTP/1.0 200 Ok\r\n\r\n""")
    response.feed("")
    assert response.headers_complete
    assert response.message_complete
    assert not response.should_keep_alive()
    assert response.should_close()
    assert response.status_code == 200
开发者ID:KLab,项目名称:geventhttpclient,代码行数:11,代码来源:test_keep_alive.py

示例6: test_keep_alive_bodyless_response_with_body

# 需要导入模块: from geventhttpclient.response import HTTPResponse [as 别名]
# 或者: from geventhttpclient.response.HTTPResponse import should_close [as 别名]
def test_keep_alive_bodyless_response_with_body():
    response = HTTPResponse(method='HEAD')
    response.feed("HTTP/1.1 200 Ok\r\n\r\n")
    assert response.should_keep_alive()

    response = HTTPResponse(method='HEAD')
    with pytest.raises(HTTPParseError):
        response.feed(
            """HTTP/1.1 200 Ok\r\nContent-Length: 10\r\n\r\n0123456789""")
    assert response.should_keep_alive()
    assert response.should_close()
开发者ID:handloomweaver,项目名称:geventhttpclient,代码行数:13,代码来源:test_keep_alive.py

示例7: test_keep_alive

# 需要导入模块: from geventhttpclient.response import HTTPResponse [as 别名]
# 或者: from geventhttpclient.response.HTTPResponse import should_close [as 别名]
def test_keep_alive():
    response = HTTPResponse()
    response.feed("""HTTP/1.1 200 Ok\r\n\r\n""")
    assert response.should_keep_alive()
    assert not response.should_close()
    assert response.status_code == 200
开发者ID:handloomweaver,项目名称:geventhttpclient,代码行数:8,代码来源:test_keep_alive.py


注:本文中的geventhttpclient.response.HTTPResponse.should_close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。