Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest, os, sys, platform, shutil, time, datetime, json, re
- import httplib2 as http
- class Helpers(object):
- @classmethod
- def SendRequest(self, target, method, body, headers, printContent=True):
- conn = http.Http(timeout=360)
- print("________________")
- print("METHOD: {0}".format(method))
- print("TARGET: {0}".format(target))
- if (printContent == True):
- print("Body: {0}".format(body))
- print("-----SEND REQUEST------")
- startRequest = time.time()
- response, content = conn.request(target, method, body, headers)
- receiveResponse = time.time()
- elapsedTime = receiveResponse - startRequest
- print("RESPONSE STATUS: {0}".format(str(response.status)))
- if (printContent==True):
- print("Body: {0}".format(content))
- print("ELAPSED TIME: {0}".format(str(elapsedTime)))
- print("________________")
- return (response, content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement