def METHOD_NAME(method, url, data=None, json=None, files=None, headers={}, auth=None, stream=None):
    try:
        proto, dummy, host, path = url.split("/", 3)
    except ValueError:
        proto, dummy, host = url.split("/", 2)
        path = ""
    if proto == "http:":
        port = 80
    elif proto == "https:":
        import ussl
        port = 443
    else:
        raise ValueError("Unsupported protocol: " + proto)
    if ":" in host:
        host, port = host.split(":", 1)
        port = int(port)
    if auth:
        headers["Authorization"] = b"Basic %s" % (
            ubinascii.b2a_base64("%s:%s" % (auth[0], auth[1]))[0:-1]
        )
    resp_code = 0
    resp_reason = None
    resp_headers = []
    ai = usocket.getaddrinfo(host, port)[0]
    s = usocket.socket(ai[0], ai[1], ai[2])
    try:
        s.connect(ai[-1])
        s.settimeout(5.0)
        if proto == "https:":
            s = ussl.wrap_socket(s, server_hostname=host)
        s.write(b"%s /%s HTTP/1.0\r\n" % (method, path))
        if "Host" not in headers:
            s.write(b"Host: %s\r\n" % host)
        # Iterate over keys to avoid tuple alloc
        for k in headers:
            s.write(k)
            s.write(b": ")
            s.write(headers[k])
            s.write(b"\r\n")
        if json is not None:
            import ujson
            data = ujson.dumps(json)
            s.write(b"Content-Type: application/json\r\n")
        if files is not None:
            data = bytearray()
            boundary = b"37a4bcce91521f74142f1868e328a6b9"
            s.write(b"Content-Type: multipart/form-data; boundary=%s\r\n" % (boundary))
            for name, fileobj in files.items():
                data += b"--%s\r\n" % (boundary)
                data += b'Content-Disposition: form-data; name="%s"; filename="%s"\r\n\r\n' % (
                    name,
                    fileobj[0],
                )
                data += fileobj[1].read()
                data += b"\r\n"
            data += b"\r\n--%s--\r\n" % (boundary)
        if data:
            s.write(b"Content-Length: %d\r\n\r\n" % len(data))
            s.write(data)
        else:
            s.write(b"\r\n")
        response = socket_readall(s).split(b"\r\n")
        while response:
            l = response.pop(0).strip()
            if not l or l == b"\r\n":
                break
            if l.startswith(b"Transfer-Encoding:"):
                if b"chunked" in l:
                    raise ValueError("Unsupported " + l)
            elif l.startswith(b"Location:") and not 200 <= status <= 299:
                raise NotImplementedError("Redirects not yet supported")
            if "HTTPS" in l or "HTTP" in l:
                sline = l.split(None, 2)
                resp_code = int(sline[1])
                resp_reason = sline[2].decode().rstrip() if len(sline) > 2 else ""
                continue
            resp_headers.append(l)
        resp_headers = b"\r\n".join(resp_headers)
        content = b"\r\n".join(response)
    except OSError:
        raise
    finally:
        s.close()
    return Response(resp_code, resp_reason, resp_headers, content)