def log_request(r):
    """ Serialize a httpx.Request object into a dict for logging """
    return {
        "method" : r.method,
        "url" : str(r.url),
        "headers" : dict(r.headers),
        "data" : r.read().decode()
    }