0

I read that HTTP Pipelining is not activated by default in modern browsers

How can I implement a Persistent HTTP Connection with Pipelining in Python (like code socket from scratch) without using requests library to download all pdf file in folder slides from http://web.stanford.edu/class/cs224w/slides/

I tried to send request from scratch many times just using import Socket and Threading (because I don't able to use requests lib or anything else like requests to automatically send request) but don't gain any result.

I made a TCP socket connection like this

client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((host, port))

After that I make many sending-thread with the request with the format like this:

request = f"GET {path}{file_name} HTTP/1.1\r\nHost:{host}\r\nConnection: Keep-Alive\r\n\r\n"

Then I make many receiving-thread to receive data but Host return the response by turn.

  • 1
    HTTP pipelining is sending multiple requests on the __same__ TCP connection __one after the other__, i.e. __not in parallel__. The responses also come on the same TCP connection one after the other, i.e. not in parallel. This means using threading is wrong here. The main difference between pipelining and plain keep-alive is that the client does not wait for the response to the previous requests to be finished before sending the next requests. The speedup you can achieve with this when loading larger files (like PDF) is practically zero, so don't bother. – Steffen Ullrich Nov 07 '22 at 06:17
  • Oh, I get it. But is there any way to download a number of PDF file in parallel on the same TCP connection or speedup when download file via sending multiple request? – Queensalats Nov 07 '22 at 07:12

0 Answers0