Skip to content

Instantly share code, notes, and snippets.

@anton-dzodzikov
Created April 1, 2016 01:56
Show Gist options
  • Select an option

  • Save anton-dzodzikov/eccb97b7cd8ea3cac488394bc9294381 to your computer and use it in GitHub Desktop.

Select an option

Save anton-dzodzikov/eccb97b7cd8ea3cac488394bc9294381 to your computer and use it in GitHub Desktop.
def send_request(url, data, method, content_type):
"""
Send HTTP request and return response
"""
opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request(url, data=data)
request.add_header('Content-Type', content_type)
request.get_method = lambda: method
return opener.open(request).read()
@anton-dzodzikov
Copy link
Author

Allows to use PUT and other methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment