FlorianREGAZ / Python-Tls-Client

Advanced HTTP Library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTP request failed

theodorebourgeon opened this issue · comments

When I try to get an HTTP url (i.e http://facebook.com) it raises an error instead or redirecting to HTTPS:

TLSClientExeption: failed to do request: Get "http://facebook.com": net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x00\x00\x12\x04\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00d\x00\x04\x00\x01\x00\x00\x00\x05\x00\xff\xff\xff\x00\x00\x04\b\x00\x00\x00\x00\x00\x7f\xff\x00\x00\x00\x00\b\a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"

Step to reproduce
import tls_client response = session.get("http://facebook.com", headers= { "upgrade-insecure-requests": "1", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Windows; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5615.138 Safari/537.36", "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "sec-ch-ua": '".Not/A)Brand";v="99", "Google Chrome";v="112", "Chromium";v="112"', "sec-ch-ua-mobile": "?0", "sec-ch-ua-platform": '"Windows"', "sec-fetch-site": "none", "sec-fetch-mod": "", "sec-fetch-user": "?1", "accept-encoding": "gzip, deflate, br", "accept-language": "bg-BG,bg;q=0.9,en-US;q=0.8,en;q=0.7", }, timeout_seconds=10, allow_redirects=True)

commented

Please use https://facebook.com instead of http://facebook.com
Should fix the issue.