문제 설명
나는 클라이언트입니다. 선택적으로 http 응답에서 헤더를 제거할 수 있습니까? (I'm client. Can I remove header from http response optionally?)
낮은 대기 시간을 얻기 위해 불필요한 헤더를 삭제하고 싶습니다. 이 쓸모없는 헤더를 삭제할 수 있습니까? 먼저 'Set‑Cookie: 헤더를 제거하고 싶습니다. 쿠키와 관련하여 준비된 요청 헤더 옵션이 있습니까? 가능하지 않은 경우 두 번째는 http2‑ALPN을 사용하는 것입니까? 도와주세요...
'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"))
참조 솔루션
방법 1:
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.
(by Http2inc、Steffen Ullrich)