Repository navigation
Server HTTP/2 Support, but HTTPX Using 1.1 #905
Copy link
Copy link
Closed
Labels
duplicateThis issue or pull request already existsThis issue or pull request already exists
Description
Original request:
:method: POST
:path: /m/m/signon?hash=eaec910d03cdb6dca059a8e4214f67204ff4c06f
:authority: www.guerrastribales.es
:scheme: https
igmobiledevice: Android
x-ig-os-name: android
x-ig-manufacturer: motorola
x-ig-model: Nexus 6
x-ig-os-version: 5.1.1
x-ig-client-version: 3.0.0
content-type: application/json; charset=UTF-8
content-length: 77
accept-encoding: gzip
user-agent: okhttp/3.12.6
["password",{"intent":"login","username":"Killtroot","password":"123456789"}]
HTTPX Request:
POST /m/m/signon?hash=eaec910d03cdb6dca059a8e4214f67204ff4c06f HTTP/1.1
host: www.guerrastribales.es
accept: */*
connection: keep-alive
accept-encoding: gzip
user-agent: Mozilla/5.0 (Linux; Android 7.1.2; AFTMM Build/NS6264; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/59.0.3071.125 Mobile Safari/537.36
content-type: application/json; charset=UTF-8
x-ig-os-name: android
x-ig-os-version: 5.1.1
x-ig-model: Nexus 6
x-ig-manufacturer: motorola
igmobiledevice: Android
content-length: 77
["password",{"intent":"login","username":"Killtroot","password":"123456789"}]
client.py
import json
import ssl
import collections
import traceback
import httpx._config
import httpx
class http_Client():
def __init__(self):
self.proxy = None
self.headers = None
self.body = None
self.params = None
self.url = None
self.method = None
self.cookies = None
self.response = None
def reset(self):
self.headers = None
self.body = None
self.params = None
self.url = None
self.method = None
self.cookies = None
self.response = None
async def run(self):
if self.headers == None:
raise Exception('Headers cant be empty')
if self.method == 'POST' and self.body == None:
raise Exception('HTTP body cant be empty')
if self.url == None:
raise Exception('URL Cant be empty')
# todo aun falta configurar las cookies en las llamadas que faltan ya que no tengo claro que llamadas meten cookies y cuales no, la mayoria de gets llevan cookies
ssl_config = httpx._config.SSLConfig()
ssl_context = ssl_config.load_ssl_context()
ssl_context.options |= getattr(ssl, "OP_NO_TLSv1_3", 0)
ssl_context.load_verify_locations(path)
# ssl_config = client_httpx.SSLConfig(verify=r'C:\Users\localhost\Documents\Enrique\charlesproxy.pem')
try:
self.headers = collections.OrderedDict(self.headers)
if self.proxy != None:
client = httpx.AsyncClient(proxies={
"http": 'http://' + self.proxy,
"https": 'http://' + self.proxy
# configuramos ssl en el cliente
}, verify=ssl_context,http2=True)
else:
client = httpx.AsyncClient(http2=True)
if self.method == 'get':
self.response = await client.get(self.url, headers=collections.OrderedDict(self.headers), params=self.params)
if self.response.history and 'login.php?mobile&sid' in self.url:
for resp in self.response.history:
zero_test = resp.headers['set-cookie']
sid_split = zero_test.split('=')
sid = sid_split[1].split(';')[0]
cid = sid_split[3].split(';')[0]
return {'sid': sid, 'cid': cid, 'html_response': self.response.text}
else:
json_data = json.loads(self.response)
return json_data
elif self.method == 'post':
# pasamos a texto cualquier cosa dentro de el body
body = str(self.body)
# mandamos a el cliente ha hacer el post
self.response = await client.post(self.url, headers=collections.OrderedDict(self.headers), params=self.params, data=body)
json_data = self.response.json()
return json_data
except Exception as e:
print(e.args)
print(traceback.print_exc())
finally:
self.reset()
as you can see im using
httpx.AsyncClient(http2=True)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
duplicateThis issue or pull request already existsThis issue or pull request already exists
Activity
qwerty32123 commentedon Apr 13, 2020
The issue is in Proxies, not in SSL according to #873 and to my personal testing, SSL is fine but if i load proxy i get HTTP 1.1 instead of HTTP 2 i get witouth it
florimondmanca commentedon Apr 13, 2020
Hi @GnubiBORED, indeed this seems to be the same issue than #873. Going to close this as duplicate to keep things nice and tidy, but it’s useful to have another example of the problem. Thanks!