So one of my work projects is sending some xml via http.
We use urllib, urllib2 to do all this work. (obviously)
I needed to check what was happening to the data being sent. Since most of the work is hidden by urllib my debugging was pretty much useless.
However urllib2 allows us to switch it to debug mode like such:
import urllib, urllib2
url = "some url"
xml = "some xml"
opener = urllib2.build_opener(httphandler)
opener.addheaders = [('Accept', 'application/xml'), ('Content-Type', 'application/xml'),]
req = urllib2.Request(url)
resp = urllib2.urlopen(req)