예제 #1
0
def test_get_header_tokens():
    headers = Headers()
    assert utils.get_header_tokens(headers, "foo") == []
    headers["foo"] = "bar"
    assert utils.get_header_tokens(headers, "foo") == ["bar"]
    headers["foo"] = "bar, voing"
    assert utils.get_header_tokens(headers, "foo") == ["bar", "voing"]
    headers.set_all("foo", ["bar, voing", "oink"])
    assert utils.get_header_tokens(headers, "foo") == ["bar", "voing", "oink"]
예제 #2
0
def test_get_header_tokens():
    h = odict.ODictCaseless()
    assert utils.get_header_tokens(h, "foo") == []
    h["foo"] = ["bar"]
    assert utils.get_header_tokens(h, "foo") == ["bar"]
    h["foo"] = ["bar, voing"]
    assert utils.get_header_tokens(h, "foo") == ["bar", "voing"]
    h["foo"] = ["bar, voing", "oink"]
    assert utils.get_header_tokens(h, "foo") == ["bar", "voing", "oink"]
예제 #3
0
def test_get_header_tokens():
    h = odict.ODictCaseless()
    assert utils.get_header_tokens(h, "foo") == []
    h["foo"] = ["bar"]
    assert utils.get_header_tokens(h, "foo") == ["bar"]
    h["foo"] = ["bar, voing"]
    assert utils.get_header_tokens(h, "foo") == ["bar", "voing"]
    h["foo"] = ["bar, voing", "oink"]
    assert utils.get_header_tokens(h, "foo") == ["bar", "voing", "oink"]
예제 #4
0
def test_get_header_tokens():
    headers = Headers()
    assert utils.get_header_tokens(headers, "foo") == []
    headers["foo"] = "bar"
    assert utils.get_header_tokens(headers, "foo") == ["bar"]
    headers["foo"] = "bar, voing"
    assert utils.get_header_tokens(headers, "foo") == ["bar", "voing"]
    headers.set_all("foo", ["bar, voing", "oink"])
    assert utils.get_header_tokens(headers, "foo") == ["bar", "voing", "oink"]
예제 #5
0
    def connection_close(self, httpversion, headers):
        """
            Checks the message to see if the client connection should be closed
            according to RFC 2616 Section 8.1 Note that a connection should be
            closed as well if the response has been read until end of the stream.
        """
        # At first, check if we have an explicit Connection header.
        if "connection" in headers:
            toks = utils.get_header_tokens(headers, "connection")
            if "close" in toks:
                return True
            elif "keep-alive" in toks:
                return False

        # If we don't have a Connection header, HTTP 1.1 connections are assumed to
        # be persistent
        return httpversion != (1, 1)
예제 #6
0
    def connection_close(self, httpversion, headers):
        """
            Checks the message to see if the client connection should be closed
            according to RFC 2616 Section 8.1 Note that a connection should be
            closed as well if the response has been read until end of the stream.
        """
        # At first, check if we have an explicit Connection header.
        if "connection" in headers:
            toks = utils.get_header_tokens(headers, "connection")
            if "close" in toks:
                return True
            elif "keep-alive" in toks:
                return False

        # If we don't have a Connection header, HTTP 1.1 connections are assumed to
        # be persistent
        return httpversion != (1, 1)
예제 #7
0
 def has_chunked_encoding(self, headers):
     return "chunked" in [
         i.lower() for i in utils.get_header_tokens(headers, "transfer-encoding")
     ]
예제 #8
0
 def has_chunked_encoding(self, headers):
     return "chunked" in [
         i.lower()
         for i in utils.get_header_tokens(headers, "transfer-encoding")
     ]