From a66c5811f8606fa0006258ceac61cc4ae2da0444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Sun, 24 Jul 2016 16:12:22 +0200 Subject: [PATCH] Support any encoding in HEAD requests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Completely support would be more problematic and this already covers most usual case. Fixes #2775 Signed-off-by: Michal Čihař --- CHANGES | 1 + sphinx/builders/linkcheck.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index 0da0a09ef8..870cf85294 100644 --- a/CHANGES +++ b/CHANGES @@ -14,6 +14,7 @@ Bugs fixed * #2778: Fix autodoc crashes if obj.__dict__ is a property method and raises exception * Fix duplicated toc in epub3 output. +* #2775: Fix failing linkcheck with servers not supporting identidy encoding Release 1.4.5 (released Jul 13, 2016) ===================================== diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index 0533f1c506..0f1716aafd 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -56,6 +56,11 @@ opener.addheaders = [('User-agent', 'Mozilla/5.0 (X11; Linux x86_64; rv:25.0) ' class HeadRequest(Request): """Subclass of urllib2.Request that sends a HEAD request.""" + def __init__(self, *args, **kwargs): + Request.__init__(self, *args, **kwargs) + # we do not parse the response in HEAD, so accepting anything is okay + self.headers['Accept-encoding'] = '*' + def get_method(self): return 'HEAD'