Fall back to GET when connection is reset.

This commit is contained in:
Bastian Kleineidam 2010-11-21 19:50:51 +01:00
parent 729a4fffc6
commit 6fac69cddb
2 changed files with 14 additions and 2 deletions

View file

@ -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.

View file

@ -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,