I am currently using the python 2.7 query library and there is no support for ordered headers. I can put the ordered data for the message and get (for example, an ordered dictionary), but there is simply no header support. Not even in python 3
I know the HTTP RFC protocol, indicates that the order of the headers is not significant, but the problem is that the third-party service that I am implementing does not work if the headers are not in order. I know this because I implemented custom header requests in other languages, and it works (like java), and yes, I am 100% sure of this, because I checked on burp and wirehark to make sure that this is the only one difference between requests, But I already have 5,000 lines in python, so migration causes such a painful solution due to such a problem.
The only solution I thought of is to implement the HTTP protocol on top of TCP itself, but this is not a reasonable solution. I cannot have the same code quality as the available solutions, and this is a possible error for my code.
See a simplified code example below:
data=(("param1","something"), ("param2","something_else")) headers={'id': 'some_random_number', 'version':'some_random_number' , 'signature':'some_random_number' , 'Content-Type':'application/x-www-form-urlencoded' , 'charset':'utf-8' , 'Content-Length':str(len(urllib.urlencode(data))) , 'name':'random' , 'User-Agent':'Firefox' , 'Connection':'Keep-Alive' , 'Accept-Encoding':'gzip'} requests.post("myservice.com",headers=headers, data=data)
The order of the request headers goes like this (not the actual order, just an example to get my point)
'version':'some_random_number' 'Accept-Encoding':'gzip' 'id': 'some_random_number' 'User-Agent':'Firefox' 'signature':'some_random_number' 'Connection':'Keep-Alive' 'Content-Type':'application/x-www-form-urlencoded' 'charset':'utf-8' 'name':'random'
This is a problem for me. I do not know what to do at this moment. Any help is greatly appreciated. I tried urllib library without support