I want to delete useless header to get lower latency. Is it possible delete these useless headers? I want to remove 'Set-Cookie: header first. Is there any prepared request header options related to cookie? If it isn't possible, second possible is using http2-ALPN? help me...
'Date: Sat, 19 Mar 2022 12:38:02 GMT',
b'Expires: -1',
b'Cache-Control: private, max-age=0',
b'Content-Type: text/html; charset=ISO-8859-1',
b'P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."',
b'Server: gws',
b'X-XSS-Protection: 0',
b'X-Frame-Options: SAMEORIGIN',
b'Set-Cookie: 1P_JAR=2022-03-19-12; expires=Mon, 18-Apr-2022 12:38:02 GMT; pat'
b'h=/; domain=.google.com; Secure',
b'Set-Cookie: NID=511=j5NUUUt5vcHCkxIH0xRujZNH3plmQnZ3gA84H5CDCvAETMxHSLp5fioV'
b'lxdPbejtuP4qU1v9tctVbN0JaZ6M1ALiNKV2M35hf42KJ16KIuhk_tpesBC5hDD70Bl-1ZxhaIl6'
b'aRS55sUmbcXSIQ9BSgFpiR4OByiOEi1hRH9OzqA; expires=Sun, 18-Sep-2022 12:38:02 G'
b'MT; path=/; domain=.google.com; HttpOnly',
b'Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2'
b'592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma'
b'=2592000; v="46,43"',
b'Accept-Ranges: none',
b'Vary: Accept-Encoding',
b'Transfer-Encoding: chunked',
b'',
b'4a92'
import socket
import ssl
import pprint
context = ssl.create_default_context()
conn = context.wrap_socket(socket.socket(socket.AF_INET),
server_hostname="www.google.com")
conn.connect(("www.google.com", 443))
conn.sendall(b"GET / HTTP/1.1\r\nHost: www.google.com:443\r\n\r\n")
pprint.pprint(conn.recv(1024).split(b"\r\n"))
CodePudding user response:
Is it possible delete ....
A client cannot remove headers the server is sending - unless the server is specifically programmed to let the client do this by instrumenting the HTTP request. Usually this is not the case.
... these useless headers?
These headers actually have a defined meaning, i.e. they are not useless.
... to get lower latency
Omitting these headers will likely not improve latency at all. Latency primarily depends on the round trip time and on the number of data exchanges were one side needs to wait for the other to continue. Costly for latency are TCP handshake and TLS handshake, but not really if the server sends a bit more data in the HTTP response.