question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Malformed header causes IndexError during header parsing

See original GitHub issue

This response (note the space and quotes around Content-type):

$ curl --head https://consumersentinel.gov
HTTP/1.0 200 OK
 "Content-type": text/html
pragma: no-cache
retry-after: 600
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Server: BigIP
Connection: Keep-Alive
Content-Length: 2835

Causes this error in urllib3:

  File "/home/eric/.pyenv/versions/2.7.11/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 590, in urlopen
    **response_kw)
  File "/home/eric/.pyenv/versions/2.7.11/lib/python2.7/site-packages/requests/packages/urllib3/response.py", line 373, in from_httplib
    headers = HTTPHeaderDict.from_httplib(headers)
  File "/home/eric/.pyenv/versions/2.7.11/lib/python2.7/site-packages/requests/packages/urllib3/_collections.py", line 317, in from_httplib
    key, value = headers[-1]
IndexError: list index out of range

I’m using urllib3 via requests, but it doesn’t look like that’s causing the issue.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Lukasacommented, Aug 18, 2016

What the hell is that monstrous header? Whomever is operating that web server needs a very stern telling off, because that output isn’t even close to acceptable.

Regardless, good debugging folks!

2reactions
haikugingercommented, Aug 18, 2016

Actually, not a difference in the parsing - found the issue, and will have a PR shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

malformed header from script 'index.php' bad header, despite ...
Try echo json_encode('hello') and see if that appears as a header in the log as well. It looks like your body is being...
Read more >
BIP5000-5999: Runtime components - Parsers - IBM
A code page converter used for character conversion could not be initialized, possibly because an invalid code page was specified in the message...
Read more >
Indexer errors and warnings - Azure Cognitive Search
This error occurs when the indexer is unable to finish processing a single document from the data source within the allowed execution time....
Read more >
Changelog — aiohttp 3.7.3 documentation
Fixed a type error caused by the conditional import of Protocol . ... When parsing the Forwarded header, the optional port number is...
Read more >
Issue 45001: Date parsing helpers in email module incorrectly ...
msg400261 ‑ (view) Author: wouter bolsterlee (wbolster) * Date: 2021‑08‑25 13:23 msg400262 ‑ (view) Author: wouter bolsterlee (wbolster) * Date: 2021‑08‑25 13:27 msg400351 ‑ (view)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found