def post_httplib(self, entry_path): url, payload = cache.read_cache(entry_path) params = urllib.urlencode(payload) headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"} _url = urlparse(SerialGrabber_Paths.urls[url]) if _url.scheme == "https": conn = httplib.HTTPSConnection(_url.hostname) else: conn = httplib.HTTPConnection(_url.hostname) conn.request("POST", _url.path, body=params, headers=headers) response = conn.getresponse() self.logger.info("HTTP Response: %s %s"%(response.status, response.reason)) data = response.read() self.logger.log(5,data) conn.close() if response.status == 200: cache.decache(entry_path)
def post_requests(self, entry_path): url, payload = cache.read_cache(entry_path) s = requests.session() s.config['keep_alive'] = False s.config['danger_mode'] = True s.config['max_retries'] = 0 s.config['pool_connections'] = 1 s.config['pool_maxsize'] = 1 r = s.post(SerialGrabber_Paths.urls[url], data=payload, verify=False) self.logger.info("Response Code: %s" % r.status_code) self.logger.debug(r.text.encode('utf8')) if r.status_code == requests.codes.ok: print "POSTED" cache.decache(entry_path) toRet = True r.raw.release_conn() del r del s
def post_httplib(self, entry_path): url, payload = cache.read_cache(entry_path) params = urllib.urlencode(payload) headers = { "Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain" } _url = urlparse(SerialGrabber_Paths.urls[url]) if _url.scheme == "https": conn = httplib.HTTPSConnection(_url.hostname) else: conn = httplib.HTTPConnection(_url.hostname) conn.request("POST", _url.path, body=params, headers=headers) response = conn.getresponse() self.logger.info("HTTP Response: %s %s" % (response.status, response.reason)) data = response.read() self.logger.log(5, data) conn.close() if response.status == 200: cache.decache(entry_path)