fix read by content-length
This commit is contained in:
parent
da3e5aade0
commit
e135292817
2 changed files with 101 additions and 29 deletions
40
tests/http_client.py
Normal file
40
tests/http_client.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
import socket
|
||||
|
||||
HOST = '172.16.1.32'
|
||||
PORT = 80
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
s.connect((HOST, PORT))
|
||||
i = 0
|
||||
while True:
|
||||
s.send(b"""GET / HTTP/1.1\r
|
||||
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7\r
|
||||
Accept-Encoding: gzip, deflate, br, zstd\r
|
||||
Accept-Language: en-US,en;q=0.9\r
|
||||
Cache-Control: no-cache\r
|
||||
Connection: keep-alive\r
|
||||
Host: meex.lol\r
|
||||
Pragma: no-cache\r
|
||||
Sec-Fetch-Dest: document\r
|
||||
Sec-Fetch-Mode: navigate\r
|
||||
Sec-Fetch-Site: none\r
|
||||
Sec-Fetch-User: ?1\r
|
||||
Upgrade-Insecure-Requests: 1\r
|
||||
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36\r
|
||||
sec-ch-ua: \"Chromium\";v=\"135\", \"Not-A.Brand\";v=\"8\"\r
|
||||
sec-ch-ua-mobile: ?0\r
|
||||
sec-ch-ua-platform: \"Linux\"\r
|
||||
\r
|
||||
""")
|
||||
|
||||
content_length = 0
|
||||
while content_length < 14564:
|
||||
data = s.recv(1024)
|
||||
if data:
|
||||
content_length += len(data)
|
||||
# print(data.decode("utf8", errors="ignore"), end="")
|
||||
else:
|
||||
print("sdfsdf")
|
||||
i += 1
|
||||
|
||||
print(i)
|
Loading…
Add table
Add a link
Reference in a new issue