Here are the examples of the python api future.backports.urllib.request.Request taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1 Examples
0
Source : mcafee.py
with Apache License 2.0
from mcafee-enterprise
with Apache License 2.0
from mcafee-enterprise
def create_socket(self, url, args):
"""
Helper function to encapsulate getting a socket
@param url - the url to fetch (query string already appended)
@param args - the file arguments as a tuple (filename, contents)
@returns the socket object
"""
log(logging.INFO, 'Request: ' + url)
if (len(args) == 0):
return self.opener.open(url)
else:
body, content_type = _encode_multipart_formdata(args)
data = 'Content-Type: ' + content_type + '\r\n'
data += 'Content-Length: ' + str(len(body)) + '\r\n\r\n'
data += body
log(logging.DEBUG, 'postdata:\r\n' + data)
headers = {'Content-Type': content_type}
req = Request(url, data, headers)
return self.opener.open(req)
def get_file_contents(self, filename):