def req_loop(): with HttpClient('www.jamwt.com', 80) as client: heads = HttpHeaders() heads.set('Host', 'www.jamwt.com') log.info(client.request('GET', '/Py-TOC/', heads)) log.info(client.request('GET', '/', heads)) a.halt()
def req_loop(): with HttpClient("www.jamwt.com", 80) as client: heads = HttpHeaders() heads.set("Host", "www.jamwt.com") log.info(client.request("GET", "/Py-TOC/", heads)) log.info(client.request("GET", "/", heads)) a.halt()
def finalize_request(self, req, env): code = int(env['diesel.status'].split()[0]) heads = HttpHeaders() for n, v in env['diesel.response_headers']: heads.add(n, v) body = ''.join(env['diesel.output']) if 'Content-Length' not in heads: heads.set('Content-Length', len(body)) return http_response(req, code, heads, body)
def finalize_request(self, req): code = int(self.status.split()[0]) heads = HttpHeaders() for n, v in self.response_headers: heads.add(n, v) body = ''.join(self.outbuf) if 'Content-Length' not in heads: heads.set('Content-Length', len(body)) return http_response(req, code, heads, body)
def __headers(self): headers = HttpHeaders() default = { "Accept": "application/xml", "Authorization": self.__authorization_header(), "Content-type": "application/xml", "User-Agent": "Braintree Python " + version.Version, "X-ApiVersion": Configuration.api_version(), } for k in default: headers.set(k, default[k]) return headers
def get_client(): client = HttpClient(host, 80) heads = HttpHeaders() heads.set('Host', host) return client, heads