-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Client use aiohttp, will be hang up ,when server return 304 #505
Labels
Comments
Sorry, I don't understand what part of aiohttp is broken. |
Here I find out an example, the client output should be Server: import socket
# Standard socket stuff:
host = ''
port = 7777
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind((host, port))
sock.listen(1)
# Loop forever, listening for requests:
while True:
csock, caddr = sock.accept()
req = csock.recv(1024) # get the request, 1kB max
print(req)
csock.send(
b'HTTP/1.1 304 NOT MODIFIED\r\n' +
b'Connection: keep-alive\r\n' +
b'\r\ntest'
)
csock.close() client: import asyncio
import aiohttp
@asyncio.coroutine
def fetch_page(url):
response = yield from aiohttp.request('GET', url)
return (yield from response.read())
content = asyncio.get_event_loop().run_until_complete(
fetch_page('http://127.0.0.1:7777')
)
print(content) |
Got it. |
carlcarl
added a commit
to carlcarl/aiohttp
that referenced
this issue
Oct 3, 2015
carlcarl
added a commit
to carlcarl/aiohttp
that referenced
this issue
Oct 3, 2015
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
As http rfc2616( http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html):
4.4 Message Length
1.Any response message which "MUST NOT" include a message-body (such as the 1xx, 204, and 304 responses and any response to a HEAD request) is always terminated by the first empty line after the header fields, regardless of the entity-header fields present in the message.
So, server return 304 without content-length header .but aiohttp client will waiting for content-length.
The text was updated successfully, but these errors were encountered: