The urllib.RequestBody Class
Yet another old idea. Where’s the patch? Here!
April 22, 2000 | Fredrik Lundh
As currently implemented, the urllib module allows you to post with a single, predefined content type (x-www-form-urlencoded).
This patch modifies urllib to accept either a string or a (subclass of) the urllib.RequestBody class.
Usage:
import urllib body = urllib.RequestBody(mydata, "text/xml") result = urllib.urlopen(host, body)
or, using the Form subclass:
body = urllib.Form(name="fredrik", email="fredrik@example.com") result = urllib.urlopen(host, body)