-
-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
peer closed connection without sending complete message body (incomplete chunked read) #1927
Comments
I think you are sending request to wrong url
would give
which is wrong url |
I'd be interested in digging into HTTP/1.0 failure cases - bit difficult right now since I don't know a publicly available URL which replicates this behaviour. (If you're up for exposing an example server that'll replicate this again, then I'll happily take the time to look into it.) |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Original patch for urllib3 is here, a already-known issue for the community. But We need to migrate this patch into |
@hi-unc1e Unclear what you're trying to say. |
Problem ScenarioI have encountered an issue when handling responses from a server, which you can set up the server (Python 3): #!/usr/bin/env python
# -*- encoding: utf-8 -*-
import socket
import threading
port = 80
def handle_request(client_socket, request):
if "chunk_error" in request:
response = bytes.fromhex("485454502f312e3120323030204f4b0d0a4163636570742d52616e6765733a2062797465730d0a436f6e74656e742d547970653a20746578742f68746d6c3b20636861727365743d5554462d380d0a446174653a204d6f6e2c203237204d617920323032342031313a31333a303120474d540d0a5365727665723a206e67696e780d0a5472616e736665722d456e636f64696e673a206368756e6b65640d0a0d0a32380d0a3c21444f43545950452068746d6c3e0d0a3c68746d6c3e3c686561642069643d226448656164223e0d0a")
client_socket.sendall(response)
client_socket.close()
else:
response = "HTTP/1.1 200 OK\n\nHello World! This is Http Server With Many Problems"
client_socket.sendall(response.encode())
client_socket.close()
def handle_client(client_socket):
request = client_socket.recv(1024).decode()
print(f"Received request: {request}")
handle_request(client_socket, request)
if __name__ == '__main__':
server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.bind(('0.0.0.0', port))
server_socket.listen(50) # Set the listening queue size
print(f"Listening on port {port}...")
while True:
client_socket, addr = server_socket.accept()
client_thread = threading.Thread(target=handle_client, args=(client_socket,))
client_thread.start() When I try to access this server using import httpx
response = httpx.get('http://127.0.0.1:80/chunk_error/')
print("Response: ", response.status_code, response.text) I encounter the following error:
Problem Analysis
Specifically, the underlying Instead, the Please feel free to reach out for any further clarifications or discussions. |
Okay. My understanding of this is that "httpx is behaving correctly and raising an exception, although the exception could be clearer". Does that match your interpretation? |
Yes, no need to fix
… From: "Tom ***@***.***>
Date: Thu, May 30, 2024, 22:38
Subject: Re: [encode/httpx] peer closed connection without sending complete message body (incomplete chunked read) (Issue #1927)
To: ***@***.***>
Cc: ***@***.***>, ***@***.***>
Okay. My understanding of this is that "httpx is behaving correctly and raising an exception, although the exception could be clearer".
Does that match your interpretation?
—
Reply to this email directly, view it on GitHub<#1927 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AQFDMBTGD6WG3VZOSYA6OM3ZE42VRAVCNFSM5HODWSGKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMJTHE3TGOJSHA3Q>.
You are receiving this because you were mentioned.[image]Message ID: ***@***.***>
|
Checklist
Describe the bug
I got the following error when sending some special requests:
httpcore.RemoteProtocolError: peer closed connection without sending complete message body (incomplete chunked read)
If use requests, must use the following code to set the HTTP version to 1.0 to succeed.
Environment
Additional context
In order to facilitate the test, I put the website of the intranet on the Internet.This URL address can be used for testing : http://27.102.107.109:7001/
The text was updated successfully, but these errors were encountered: