mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-17 06:20:27 +00:00
Fall back to GET when connection is reset.
This commit is contained in:
parent
729a4fffc6
commit
6fac69cddb
2 changed files with 14 additions and 2 deletions
|
|
@ -1,6 +1,9 @@
|
|||
6.0 "" (released xx.xx.2010)
|
||||
|
||||
Fixes:
|
||||
- checking: Fall back to HTTP GET requests when the connection has
|
||||
been resets since some servers tend to do this for HEAD requests.
|
||||
Closes: SF bug #3114622
|
||||
|
||||
Changes:
|
||||
- dependencies: Require and use Python 2.6.
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ Handle http links.
|
|||
import urlparse
|
||||
import urllib
|
||||
import re
|
||||
import errno
|
||||
import zlib
|
||||
import socket
|
||||
from cStringIO import StringIO
|
||||
|
|
@ -40,8 +41,7 @@ from .const import WARN_HTTP_ROBOTS_DENIED, \
|
|||
# helper alias
|
||||
unicode_safe = strformat.unicode_safe
|
||||
|
||||
supportHttps = hasattr(httplib, "HTTPSConnection") and \
|
||||
hasattr(socket, "ssl")
|
||||
supportHttps = hasattr(httplib, "HTTPSConnection")
|
||||
|
||||
_supported_encodings = ('gzip', 'x-gzip', 'deflate')
|
||||
|
||||
|
|
@ -185,6 +185,15 @@ class HttpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport):
|
|||
self.fallback_get = True
|
||||
continue
|
||||
raise
|
||||
except socket.error, msg:
|
||||
# some servers reset the connection on HEAD requests
|
||||
if self.method == "HEAD" and self.method_get_allowed and \
|
||||
msg[0] == errno.ECONNRESET:
|
||||
self.method = "GET"
|
||||
self.aliases = []
|
||||
self.fallback_get = True
|
||||
continue
|
||||
raise
|
||||
if response.reason:
|
||||
response.reason = unicode_safe(response.reason)
|
||||
log.debug(LOG_CHECK,
|
||||
|
|
|
|||
Loading…
Reference in a new issue