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 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. 3
0
 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)
Esempio n. 4
0
 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)
Esempio n. 5
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. 6
0
File: wsgi.py Progetto: dowski/aspen
 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. 7
0
    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
Esempio n. 8
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. 9
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. 10
0
File: ws.py Progetto: dowski/aspen
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. 11
0
def DieselReq():
    diesel_request = HttpRequest('GET', '/', 'HTTP/1.1')
    diesel_request.headers = HttpHeaders(Host='localhost')  # else 400
    return diesel_request
Esempio n. 12
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. 13
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. 14
0
def get_client():
    client = HttpClient(host, 80)
    heads = HttpHeaders()
    heads.set('Host', host)
    return client, heads