Fix overwritten Accept header when proxy is used (#916725)

This commit is contained in:
Ralph Bean 2013-03-01 10:28:27 -05:00
parent e2c2602a24
commit 23a06f9568
2 changed files with 46 additions and 5 deletions

View File

@ -0,0 +1,28 @@
From ea36acfc8a997a19ba1ead58de0d1f01e9eb540f Mon Sep 17 00:00:00 2001
From: kevin <kevinbjiang@gmail.com>
Date: Thu, 30 Aug 2012 00:14:12 -0400
Subject: [PATCH 1/4] Fix overwritten Accept header when proxy is used
When a request specifies both an Accept header and a proxy server, the
Accept header value is overwritten.
---
urllib3/poolmanager.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/urllib3/poolmanager.py b/urllib3/poolmanager.py
index 8f5b54c..7d7d6e4 100644
--- a/urllib3/poolmanager.py
+++ b/urllib3/poolmanager.py
@@ -141,7 +141,8 @@ def _set_proxy_headers(self, headers=None):
headers = headers or {}
# Same headers are curl passes for --proxy1.0
- headers['Accept'] = '*/*'
+ if 'Accept' not in headers:
+ headers['Accept'] = '*/*'
headers['Proxy-Connection'] = 'Keep-Alive'
return headers
--
1.7.10

View File

@ -8,23 +8,31 @@
Name: python-%{srcname}
Version: 1.5
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Python HTTP library with thread-safe connection pooling and file post
License: MIT
URL: http://urllib3.readthedocs.org/
Source0: http://pypi.python.org/packages/source/u/%{srcname}/%{srcname}-%{version}.tar.gz
# Patch to change default behaviour to check SSL certs for validity
# https://bugzilla.redhat.com/show_bug.cgi?id=855320
Patch0: python-urllib3-default-ssl-cert-validate.patch
### TODO: Send this to upstream urllib3
# make all imports of things in packages try system copies first
Patch1: python-urllib3-unbundle.patch
### TODO: Send this upstream
# Compatibility with python-2.6's unittest
Patch2: python-urllib3-py2.6-compat.patch
# Fix accept header when behind a proxy
#https://github.com/shazow/urllib3/pull/93
#https://github.com/shazow/urllib3/pull/93.patch
Patch2: python-urllib3-accept-header-for-proxy.patch
# Remove logging-clear-handlers from setup.cfg because it's not available in RHEL6's nose
Patch100: python-urllib3-old-nose-compat.patch
### TODO: Send this upstream
# Compatibility with python-2.6's unittest
Patch101: python-urllib3-py2.6-compat.patch
BuildArch: noarch
@ -78,9 +86,10 @@ rm -rf urllib3/packages/ordered_dict*
%patch0 -p1
%patch1 -p1
%patch2 -p1
%if 0%{?rhel} && 0%{?rhel} <= 6
%patch100 -p1
%patch2 -p1
%patch101 -p1
%endif
%if 0%{?with_python3}
@ -135,6 +144,10 @@ popd
%endif # with_python3
%changelog
* Fri Mar 01 2013 Ralph Bean <rbean@redhat.com> - 1.5-4
- Upstream patch to fix Accept header when behind a proxy.
- Reorganize patch numbers to more clearly distinguish them.
* Wed Feb 27 2013 Ralph Bean <rbean@redhat.com> - 1.5-3
- Renamed patches to python-urllib3-*
- Fixed ssl check patch to use the correct cert path for Fedora.