Python-Tls-Client icon indicating copy to clipboard operation
Python-Tls-Client copied to clipboard

Response headers dict is not case insensitive

Open Phuker opened this issue 1 year ago • 0 comments

Behavior of tls_client:

import tls_client

sess = tls_client.Session(
    client_identifier='chrome_120',
    random_tls_extension_order=True,
)
resp = sess.get('https://www.example.com/')

print(type(resp.headers)) # <class 'dict'>

print(resp.headers.get('Server')) # ECAcc (lac/55CB)
print(resp.headers['Server']) # ECAcc (lac/55CB)

print(resp.headers.get('sErVeR')) # None
print(resp.headers['sErVeR']) # KeyError: 'sErVeR'

This is behavior of requests as a contrast:

import requests

sess = requests.Session()
resp = sess.get('https://www.example.com/')

print(type(resp.headers)) # <class 'requests.structures.CaseInsensitiveDict'>

print(resp.headers.get('Server')) # ECAcc (lac/55D7)
print(resp.headers['Server']) # ECAcc (lac/55D7)

print(resp.headers.get('sErVeR')) # ECAcc (lac/55D7)
print(resp.headers['sErVeR']) # ECAcc (lac/55D7)

Version info:

  • tls_client version: 1.0.1
  • Python version: 3.12.6

Thank you!

Phuker avatar Sep 25 '24 23:09 Phuker