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 __init__(self, headers): """Takes headers as a string. """ diesel_headers = DieselHeaders() diesel_headers.parse(headers) self._diesel_headers = diesel_headers Mapping.__init__(self) self._dict.update(diesel_headers._headers)
def __init__(self, headers): """Takes headers as a string. """ diesel_headers = DieselHeaders() diesel_headers.parse(headers) self._diesel_headers = diesel_headers Mapping.__init__(self) self._dict.update(diesel_headers._headers)
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 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 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 web_handler(req): heads = HttpHeaders() heads.add('Content-Length', len(content)) heads.add('Content-Type', 'text/html') return http_response(req, 200, heads, content)
def DieselReq(): diesel_request = HttpRequest('GET', '/', 'HTTP/1.1') diesel_request.headers = HttpHeaders(Host='localhost') # else 400 return diesel_request
def web_handler(req): heads = HttpHeaders() heads.add('Content-Length', len(content)) heads.add('Content-Type', 'text/html') return http_response(req, 200, heads, content)
def DieselReq(path='/'): diesel_request = HttpRequest('GET', path, 'HTTP/1.1') diesel_request.headers = HttpHeaders( Host='localhost') # else 400 in hydrate return diesel_request
def get_client(): client = HttpClient(host, 80) heads = HttpHeaders() heads.set('Host', host) return client, heads