green380 / green380 / http /

import green380
import urllib.parse

def get(url, timeout=None):
    timeout = green380.Timeout(timeout)
    split = urllib.parse.urlsplit(url)
    sock = green380.Socket()
    addr = split.netloc.split(':')
    if len(addr) == 1:
        addr[-1] = int(addr[-1])
    addr = tuple(addr)
    yield from timeout.multiplex(sock.connect(addr))
    def send_header():
        return sock.sendall(
            'GET {split[2]}?{split[3]} HTTP/1.1\r\nHost: {addr[0]}\r\nConnection: close\r\n\r\n'.format(
                split=split, addr=addr).encode())
    response_header_lines = (yield from timeout.multiplex(sock.recv_until(b'\r\n\r\n'))).split(b'\r\n')
    headers = collections.defaultdict(list)
    for l in map(bytes.decode, response_header_lines[1:]):
        if not l:
        h, *v = l.split(':', 1)
    return response_header_lines[0].decode(), headers, sock
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.