나는 클라이언트입니다. 선택적으로 http 응답에서 헤더를 제거할 수 있습니까? (I'm client. Can I remove header from http response optionally?)


문제 설명

나는 클라이언트입니다. 선택적으로 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 Http2incSteffen Ullrich)

참조 문서

  1. I'm client. Can I remove header from http response optionally? (CC BY‑SA 2.5/3.0/4.0)

#web-crawler #cookies #sockets #HTTP #HTTPS






관련 질문

UnicodeError: URL에 ASCII가 아닌 문자가 포함되어 있습니다(Python 2.7). (UnicodeError: URL contains non-ASCII characters (Python 2.7))

크롤링 출력 - 두 변수 연결 (Crawling output - connecting two variables)

Python2.7에서 효과적인 크롤러를 만드는 방법 (How to make an effective crawler in Python2.7)

이 텍스트가 다른 기사의 일부임을 Google에 알리는 방법 (How to tell google this text is part of another article)

크롤링하는 HTML 페이지에서 JavaScript 개체를 구문 분석하는 방법은 무엇입니까? (How to parse a JavaScript object from a HTML page I crawl?)

데이터 크롤링 또는 API 사용 (Crawling data or using API)

파이썬을 사용하여 웹사이트에서 내부 링크만 크롤링 (Crawl only internal links from a website using python)

받은 응답에서 HTML 코드를 긁는 방법은 무엇입니까? (How to scrape the html code from the response received?)

PHP를 사용하여 웹 사이트에서 클래스 이름 스크래핑 (Scraping class name on a website using php)

Scrapy Spider를 사용하는 Craigslist Scraper가 기능을 수행하지 않음 (Craigslist Scraper using Scrapy Spider not performing functions)

BeautifulSoup: 이 링크에서 모든 기사 링크를 가져오는 방법은 무엇입니까? (BeautifulSoup: how to get all article links from this link?)

나는 클라이언트입니다. 선택적으로 http 응답에서 헤더를 제거할 수 있습니까? (I'm client. Can I remove header from http response optionally?)







코멘트