Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (36 sloc) 1.06 KB
import httplib
def get(host, path, port = 80):
con = httplib.HTTPConnection(host, port)
con.request('GET', path)
response = con.getresponse()
contents = response.read()
con.close()
return response.status, contents
def post(host, path, data, port = 80):
con = httplib.HTTPConnection(host, port)
con.request('POST', path, data)
response = con.getresponse()
contents = response.read()
con.close()
return response.status, contents
def put(host, path, data, port = 80):
con = httplib.HTTPConnection(host, port)
con.request('PUT', path, data)
response = con.getresponse()
contents = response.read()
con.close()
return response.status, contents
def delete(host, path, port = 80):
con = httplib.HTTPConnection(host, port)
con.request('DELETE', path)
response = con.getresponse()
contents = response.read()
con.close()
return response.status, contents
def options(host, path, port = 80):
con = httplib.HTTPConnection(host, port)
con.request('OPTIONS', path)
response = con.getresponse()
contents = response.read()
con.close()
return response.status, contents
Jump to Line
Something went wrong with that request. Please try again.