Esempio n. 1
0
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()
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)
Esempio n. 4
0
def DieselReq():
    diesel_request = HttpRequest('GET', '/', 'HTTP/1.1')
    diesel_request.headers = HttpHeaders(Host='localhost')  # else 400
    return diesel_request
Esempio n. 5
0
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)
Esempio n. 6
0
def DieselReq(path='/'):
    diesel_request = HttpRequest('GET', path, 'HTTP/1.1')
    diesel_request.headers = HttpHeaders(
        Host='localhost')  # else 400 in hydrate
    return diesel_request
Esempio n. 7
0
def get_client():
    client = HttpClient(host, 80)
    heads = HttpHeaders()
    heads.set('Host', host)
    return client, heads