Advertisement
Guest User

sendRequest

a guest
Dec 13th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. import unittest, os, sys, platform, shutil, time, datetime, json, re
  2. import httplib2 as http
  3.  
  4. class Helpers(object):
  5.     @classmethod
  6.     def SendRequest(self, target, method, body, headers, printContent=True):
  7.         conn = http.Http(timeout=360)
  8.         print("________________")
  9.         print("METHOD: {0}".format(method))
  10.         print("TARGET: {0}".format(target))
  11.         if (printContent == True):
  12.             print("Body: {0}".format(body))
  13.         print("-----SEND REQUEST------")
  14.         startRequest = time.time()
  15.         response, content = conn.request(target, method, body, headers)
  16.         receiveResponse = time.time()
  17.         elapsedTime = receiveResponse - startRequest
  18.  
  19.         print("RESPONSE STATUS: {0}".format(str(response.status)))
  20.         if (printContent==True):
  21.             print("Body: {0}".format(content))
  22.         print("ELAPSED TIME: {0}".format(str(elapsedTime)))
  23.         print("________________")
  24.         return (response, content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement