Python Proxy Test: Difference between revisions
From Federal Burro of Information
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
password = "Sc@lar2016!" | password = "Sc@lar2016!" | ||
userAndPass = b64encode(b"s-scalarcloudmgt: | userAndPass = b64encode(b"s-scalarcloudmgt:XXX").decode("ascii") | ||
print userAndPass | print userAndPass | ||
headers = { 'Authorization' : 'Basic %s' % userAndPass } | headers = { 'Authorization' : 'Basic %s' % userAndPass } |
Latest revision as of 18:04, 29 May 2017
#!/usr/bin/env python from base64 import b64encode import httplib import pprint pp = pprint.PrettyPrinter(indent=4) c = httplib.HTTPConnection('XXX:8080') username = "s-scalarcloudmgt" password = "Sc@lar2016!" userAndPass = b64encode(b"s-scalarcloudmgt:XXX").decode("ascii") print userAndPass headers = { 'Authorization' : 'Basic %s' % userAndPass } pp.pprint(headers) #then connect c.request('GET', '/', headers=headers) # c.request('GET', '/') #get the response back res = c.getresponse() print "read()" pp.pprint(res.read()) print "" print "headers" pp.pprint(res.getheaders()) print "" print "status" pp.pprint(res.status) print "" print "reason" pp.pprint(res.reason) pp.pprint(res) # at this point you could check the status etc # this gets the page text data = res.read()