1 import httplib
2 import mimetypes
3
4 -def post_multipart(host, selector, fields, files, secure=True):
5 content_type, body = encode_multipart_formdata(fields, files)
6 h = secure and httplib.HTTPSConnection(host) or httplib.HTTPConnection(host)
7 headers = {
8 'User-Agent': 'INSERT USERAGENTNAME',
9 'Content-Type': content_type
10 }
11 h.request('POST', selector, body, headers)
12 res = h.getresponse()
13 return res.status, res.reason, res.read()
14
15
41
42 -def get_content_type(filename):
43 return mimetypes.guess_type(filename)[0] or 'application/octet-stream'
44
45
46 -def get(host, selector, secure):
47 h = secure and httplib.HTTPSConnection(host) or httplib.HTTPConnection(host)
48 h.request('GET', selector)
49 res = h.getresponse()
50 return res.status, res.reason, res.read()
51