Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

http.client.HTTPException: got more than 100 headers

Since google did not find anything regarding error "http.client.HTTPException: got more than 100 headers", I created this question.

>>> import http.client as h
>>> conn = h.HTTPConnection("www.coursefinders.com")
>>> conn.request("HEAD","/")
>>> conn.getresponse();
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/http/client.py", line 1148, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 376, in begin
    self.headers = self.msg = parse_headers(self.fp)
  File "/usr/lib/python3.4/http/client.py", line 267, in parse_headers
    raise HTTPException("got more than %d headers" % _MAXHEADERS)
http.client.HTTPException: got more than 100 headers

What does this exception mean and how should I properly handle this type of error? Site works OK in browser.

like image 470
gadelat Avatar asked Dec 04 '22 06:12

gadelat


2 Answers

Here is a solution that doesn't involve changing library's py files:

import httplib  # or http.client if you're on Python 3
httplib._MAXHEADERS = 1000

Just put that at the top of your code

like image 88
VitalyB Avatar answered Dec 08 '22 05:12

VitalyB


change the value of "_MAXHEADERS" to 1000 or 10000 in C:\Python27\Lib\httplib.py

like image 42
Felix Avatar answered Dec 08 '22 05:12

Felix