http: Add keep alive header to the requests.
This commit is contained in:
parent
808f652d5f
commit
5e7cd9e504
1 changed files with 5 additions and 3 deletions
|
@ -50,6 +50,7 @@ class HttpRequest:
|
||||||
# type: (...) -> None
|
# type: (...) -> None
|
||||||
user_agent = 'User-Agent: {agent}'.format(agent=user_agent)
|
user_agent = 'User-Agent: {agent}'.format(agent=user_agent)
|
||||||
host_header = 'Host: {host}'.format(host=host)
|
host_header = 'Host: {host}'.format(host=host)
|
||||||
|
keepalive = "Connection: keep-alive"
|
||||||
request_list = [] # type: List[str]
|
request_list = [] # type: List[str]
|
||||||
accept_header = 'Accept: */*' # type: str
|
accept_header = 'Accept: */*' # type: str
|
||||||
end_separator = '\r\n' # type: str
|
end_separator = '\r\n' # type: str
|
||||||
|
@ -59,7 +60,8 @@ class HttpRequest:
|
||||||
if request_type == RequestType.GET:
|
if request_type == RequestType.GET:
|
||||||
get = 'GET {location} HTTP/1.1'.format(location=location)
|
get = 'GET {location} HTTP/1.1'.format(location=location)
|
||||||
request_list = [
|
request_list = [
|
||||||
get, host_header, user_agent, accept_header, end_separator
|
get, host_header, user_agent, keepalive, accept_header,
|
||||||
|
end_separator
|
||||||
]
|
]
|
||||||
|
|
||||||
elif (request_type == RequestType.POST or
|
elif (request_type == RequestType.POST or
|
||||||
|
@ -80,8 +82,8 @@ class HttpRequest:
|
||||||
length=len(json_data))
|
length=len(json_data))
|
||||||
|
|
||||||
request_list = [
|
request_list = [
|
||||||
request_line, host_header, user_agent, accept_header,
|
request_line, host_header, user_agent, keepalive,
|
||||||
length_header, type_header, end_separator
|
accept_header, length_header, type_header, end_separator
|
||||||
]
|
]
|
||||||
payload = json_data
|
payload = json_data
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue