Created
December 24, 2014 13:36
-
-
Save huseyinyilmaz/32e132835d47c7c716aa to your computer and use it in GitHub Desktop.
Code that prints all http requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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