Skip to content

help how to send raw http response #7362

Answered by thedtvn
thedtvn asked this question in Q&A
Discussion options

You must be logged in to vote

this is how to foword tcp req

import asyncio
from hola_proxy import get_proxy
import aiohttp
import base64
from aiohttp import web

class TCPReader(asyncio.StreamReader):
    def feed_data(self, data: bytes):
        super().feed_data(data)
        return (False, 1)

@web.middleware
async def handle(request: web.Request, handler):
    print(request.method)
    print(request.url)
    print(request.headers)


    proxylist = await get_proxy()
    proxy = proxylist[0]
    print(proxy)
    reader, writer = await asyncio.open_connection(proxy.host, proxy.port)
    headers_proxy = [f"{k}: {v}" for k, v in request.headers.items()]
    auth = base64.urlsafe_b64encode(f"{proxy.user}:{proxy.password}"

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@thedtvn
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by thedtvn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants