jjlee / mechanize

Stateful programmatic web browsing in Python, after Andy Lester's Perl module WWW::Mechanize .
http://wwwsearch.sourceforge.net/mechanize/
618 stars 121 forks source link

Traceback with multiple content-type headers #18

Closed jjlee closed 14 years ago

jjlee commented 14 years ago

From Felix Heß

trying to read www.cortalconsors.de with mechanize fails. The problem is in _http.py in the function http_response (line 197). Calling

ct_hdrs = http_message.getheaders("content-type")

returns [''] sometimes. Then is_html(ct_hdrs, url, self._allow_xhtml) fails.

proposed bugfix:

if '' in ct_hdrs:
    ct_hdrs.remove('')

before calling

if is_html(ct_hdrs, url, self._allow_xhtml):

I hope this information helps you to resolve the bug.

Best regards Felix

jjlee commented 14 years ago

Fix IndexError on empty Content-type header value

Closed by 346c364f1991ee416b6dddf579f85b74b51d28d3