From 15b2374ef9d6a8cbafdff7c79694921387836ff3 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 31 May 2016 18:54:42 +1200 Subject: netlib.utils.get_header_tokens -> netlib.http1.read.get_header_tokens Placing this next to its only use. --- netlib/http/http1/read.py | 14 +++++++++++++- netlib/utils.py | 12 ------------ 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'netlib') diff --git a/netlib/http/http1/read.py b/netlib/http/http1/read.py index 93fca04e..5783ec67 100644 --- a/netlib/http/http1/read.py +++ b/netlib/http/http1/read.py @@ -9,6 +9,18 @@ from .. import Request, Response, Headers from .. import url +def get_header_tokens(headers, key): + """ + Retrieve all tokens for a header key. A number of different headers + follow a pattern where each header line can containe comma-separated + tokens, and headers can be set multiple times. + """ + if key not in headers: + return [] + tokens = headers[key].split(",") + return [token.strip() for token in tokens] + + def read_request(rfile, body_size_limit=None): request = read_request_head(rfile) expected_body_size = expected_http_body_size(request) @@ -148,7 +160,7 @@ def connection_close(http_version, headers): """ # At first, check if we have an explicit Connection header. if "connection" in headers: - tokens = utils.get_header_tokens(headers, "connection") + tokens = get_header_tokens(headers, "connection") if "close" in tokens: return True elif "keep-alive" in tokens: diff --git a/netlib/utils.py b/netlib/utils.py index 91da471b..a2d8c97d 100644 --- a/netlib/utils.py +++ b/netlib/utils.py @@ -177,18 +177,6 @@ def is_valid_port(port): return 0 <= port <= 65535 -def get_header_tokens(headers, key): - """ - Retrieve all tokens for a header key. A number of different headers - follow a pattern where each header line can containe comma-separated - tokens, and headers can be set multiple times. - """ - if key not in headers: - return [] - tokens = headers[key].split(",") - return [token.strip() for token in tokens] - - def hostport(scheme, host, port): """ Returns the host component, with a port specifcation if needed. -- cgit v1.2.3