Skip to content

Instantly share code, notes, and snippets.

@huseyinyilmaz
Created December 24, 2014 13:36
Show Gist options
  • Save huseyinyilmaz/32e132835d47c7c716aa to your computer and use it in GitHub Desktop.
Save huseyinyilmaz/32e132835d47c7c716aa to your computer and use it in GitHub Desktop.
Code that prints all http requests
import httplib
def patch_send():
if hasattr(httplib, 'is_patched'):
print 'httplib is already patched'
return
httplib.is_patched = True
old_send = httplib.HTTPConnection.send
def new_send(self, data):
print data
# return is not necessary, but never hurts,
# in case the library is changed
return old_send(self, data)
httplib.HTTPConnection.send = new_send
patch_send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment