import urllib.request, urllib.error, urllib.parse
import simplejson as json


class ChangeTypeProcessor(BaseHandler):

    def http_request(self, req):
        req.unredirected_hdrs['Content-type'] = 'application/json'
return req
opener = urllib.request.build_opener()
self.opener.add_handler(ChangeTypeProcessor())
response = opener.open('http://localhost:8000', json.dumps({'a': 'b'}))
Not possible to set content-type to application/json using urllib2