ref: refs/heads/SuSE-Code-11-Branch
commit b9dd8b27c58b3e4e2b4771957239a3b533b4007d
Author: Ján Kupec
Date: Fri Oct 9 15:35:55 2009 +0200
Follow redirections also for https (bnc #545722).
- also raised the limit of redirections from 3 to 6 (bnc #465532)
---
zypp/media/MediaCurl.cc | 46 ++++++++++++++++++++++------------------------
1 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/zypp/media/MediaCurl.cc b/zypp/media/MediaCurl.cc
index 82ec9b5..2908f3b 100644
--- a/zypp/media/MediaCurl.cc
+++ b/zypp/media/MediaCurl.cc
@@ -426,31 +426,30 @@ void MediaCurl::attachTo (bool next)
ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
}
- if ( _url.getScheme() == "http" ) {
- // follow any Location: header that the server sends as part of
- // an HTTP header (#113275)
- ret = curl_easy_setopt ( _curl, CURLOPT_FOLLOWLOCATION, true );
- if ( ret != 0) {
- disconnectFrom();
- ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
- }
- ret = curl_easy_setopt ( _curl, CURLOPT_MAXREDIRS, 3L );
- if ( ret != 0) {
- disconnectFrom();
- ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
- }
-
- ret = curl_easy_setopt ( _curl, CURLOPT_USERAGENT, agentString() );
+ // follow any Location: header that the server sends as part of
+ // an HTTP header (#113275)
+ ret = curl_easy_setopt ( _curl, CURLOPT_FOLLOWLOCATION, true );
+ if ( ret != 0) {
+ disconnectFrom();
+ ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
+ }
+ // 3 redirects seem to be too few in some cases (bnc #465532)
+ ret = curl_easy_setopt ( _curl, CURLOPT_MAXREDIRS, 6L );
+ if ( ret != 0) {
+ disconnectFrom();
+ ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
+ }
+ if ( _url.getScheme() == "https" )
+ {
+ // restrict following of redirections from https to https only
+ ret = curl_easy_setopt ( _curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS );
if ( ret != 0) {
disconnectFrom();
ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
}
- }
- if ( _url.getScheme() == "https" )
- {
bool verify_peer = false;
bool verify_host = false;
@@ -522,13 +521,12 @@ void MediaCurl::attachTo (bool next)
disconnectFrom();
ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
}
+ }
- ret = curl_easy_setopt ( _curl, CURLOPT_USERAGENT, agentString() );
- if ( ret != 0) {
- disconnectFrom();
- ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
- }
-
+ ret = curl_easy_setopt ( _curl, CURLOPT_USERAGENT, agentString() );
+ if ( ret != 0) {
+ disconnectFrom();
+ ZYPP_THROW(MediaCurlSetOptException(_url, _curlError));
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org