The existing pyamf library relies on the urllib2 module to send and receive HTTP requests.
As some of you may be aware of, urllib2 can only create closed connections.
Comparing with live packets form the browser and you'll discover they use open connections instead.

I'm not sure if this contributes to detectability of existing scripts that use the original pyamf library...

I'm looking to rebuild pyamf client module using (you need an account to see links), which supports open connections.
However, urllib2 uses the concept of opener while requests uses the concept of session.
In urllib2, HTTP requests are a two-step process: building the request itself and using the opener to execute the request.
Yet in requests, HTTP requests are one-step as the request headers, cookies and stuff can be built through the requests.Session() constructor and passing
requests.cookies = cookielib.LWPCookieJar() and requests.headers = dict()

Currently in the pyamf client module there are some relevant methods for sending the HTTP request:
building urllib2 request:
  • execute
  • execute_single

using urllib2 opener:
  • _getResponse


If anyone here could give me some advice on how to quickly replace urllib2 methods with requests alternatives that would be great
Of course, there might be some workaround to get urllib2 to send POST requests with an open connection, please let me know