本文介绍了http.client.HTTPException:拥有超过100个标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于google没有找到与错误"http.client.HTTPException:有超过100个标头"有关的任何内容,因此我创建了这个问题.

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.

推荐答案

以下是不涉及更改库的py文件的解决方案:

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

这篇关于http.client.HTTPException:拥有超过100个标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 08:03