Skip to content
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

3.4.4 - invalid constant string when no response headers. #3402

Closed
niemyjski opened this issue Nov 20, 2018 · 6 comments
Closed

3.4.4 - invalid constant string when no response headers. #3402

niemyjski opened this issue Nov 20, 2018 · 6 comments

Comments

@niemyjski
Copy link

niemyjski commented Nov 20, 2018

I noticed that my request are failing and that no response headers are returned when this happens. If I go into chrome and click copy response headers it gives me HTTP/0.9 200 OK

Traceback (most recent call last):
  File "/Users/blake/Code/home-assistant-fork/lib/python3.7/site-packages/aiohttp/client_reqrep.py", line 757, in start
    message, payload = await self._protocol.read()
  File "/Users/blake/Code/home-assistant-fork/lib/python3.7/site-packages/aiohttp/streams.py", line 543, in read
    await self._waiter
  File "/Users/blake/Code/home-assistant-fork/lib/python3.7/site-packages/aiohttp/client_proto.py", line 195, in data_received
    messages, upgraded, tail = self._parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadHttpMessage: 400, message='invalid constant string'

image

@aio-libs-bot
Copy link

GitMate.io thinks the contributor most likely able to help you is @asvetlov.

Possibly related issues are #3219 (Header parsing regression in 3.4 w/ empty headers), #659 (Invalid Header stops processing Body?), #3118 (3.4.0 release), #2120 (Invalid content-type header causes LookupError), and #506 (cannot alter response headers from middleware for started StreamResponses).

@niemyjski
Copy link
Author

I tried converting this over to use a request lib and got a slightly different error of which I hope this can help:

Traceback (most recent call last):
  File "/Users/blake/Code/home-assistant-fork/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/Users/blake/Code/home-assistant-fork/lib/python3.7/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/Users/blake/Code/home-assistant-fork/lib/python3.7/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 278, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: {"valve1_Currentstatus":"Off","degree_symbol":"&degF","valve1Setpoint":"100","valve1outlet1":true,"valve1outlet2":false,"valve1outlet3":false,"valve1outlet4":false,"valve1outlet5":false,"valve1outlet6":false,"valve1_massage":0,"valve2_Currentstatus":"","valve2Setpoint":"100","valve2outlet1":false,"valve2outlet2":false,"valve2outlet3":false,"valve2outlet4":false,"valve2outlet5":false,"valve2outlet6":false,"valve2_massage":0,"steamStatus":"","steamTempStatus":"110","steamTimeStatus":"-9:00","steamTimeMinutes":"-9","LZ1Status":"Off","LZ2Status":"Off","LZ3Status":"Off","RainpanelStatus":"Off","light_attach":"0","light_remove":"0","light_turnoff1":"0","light_turnoff2":"0","light_turnoff3":"0","spa_on":false,"ui_shower_on":false,"ui_steam_running":false,"devices_running":false}

@asvetlov
Copy link
Member

HTTP/0.9 200 OK means HTTP 0.9, the protocol was introduced in 1991 (the year when Python 0.9 was released).
aiohttp supports HTTP 0.9 but I suspect that your server is not 0.9 complaint a little, e.g. the line separator is not \r\n.

Browsers have a lot of tricks to parse malformed HTTP messages but aiohttp handles HTTP RFCs plus very limited set of workarounds, sorry.

@niemyjski
Copy link
Author

Is there any chance we can get a work around for this? There is nothing I can do about this web server it's on my local network and is out of my control.

@asvetlov
Copy link
Member

Sorry, aiohttp cannot help you.
Build HTTP request data, send it through the socket, get back an answer and parse it.
Should be an easy exercise for HTTP 0.9, the protocol has a really simple structure.

@lock
Copy link

lock bot commented Nov 22, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Nov 22, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants