From 3b422ab4b2df243f48330a3329e98c9506d791c6 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 27 Apr 2011 10:32:53 +0200 Subject: * methods/http.cc: - add config option to ignore a closed stdin to be able to easily use the method as a simple standalone downloader --- methods/http.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index dfc1619e3..26abc14d9 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -778,9 +778,10 @@ bool HttpMethod::Go(bool ToFile,ServerState *Srv) if (Srv->In.WriteSpace() == true && ToFile == true && FileFD != -1) FD_SET(FileFD,&wfds); - + // Add stdin - FD_SET(STDIN_FILENO,&rfds); + if (_config->FindB("Acquire::http::DependOnSTDIN", true) == true) + FD_SET(STDIN_FILENO,&rfds); // Figure out the max fd int MaxFd = FileFD; @@ -1113,7 +1114,13 @@ int HttpMethod::Loop() do a WaitFd above.. Otherwise the FD is closed. */ int Result = Run(true); if (Result != -1 && (Result != 0 || Queue == 0)) - return 100; + { + if(FailReason.empty() == false || + _config->FindB("Acquire::http::DependOnSTDIN", true) == true) + return 100; + else + return 0; + } if (Queue == 0) continue; -- cgit v1.2.3-70-g09d2 From 4992469e453490e4c104a1b6021e48c725c499b8 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 29 Apr 2011 01:20:44 +0200 Subject: Location header in redirects should be absolute URI, but some servers just send an absolute path so still deal with it properly --- debian/changelog | 4 +++- methods/http.cc | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'methods') diff --git a/debian/changelog b/debian/changelog index 143661b87..fd10e0fcf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -48,8 +48,10 @@ apt (0.8.14.2) UNRELEASED; urgency=low * methods/http.cc: - add config option to ignore a closed stdin to be able to easily use the method as a simple standalone downloader + - Location header in redirects should be absolute URI, but some + servers just send an absolute path so still deal with it properly - -- David Kalnischkies Wed, 27 Apr 2011 10:30:47 +0200 + -- David Kalnischkies Wed, 27 Apr 2011 17:37:58 +0200 apt (0.8.14.1) unstable; urgency=low diff --git a/methods/http.cc b/methods/http.cc index 26abc14d9..d3e00553c 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -948,7 +948,23 @@ HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv) && Srv->Result != 304 // Not Modified && Srv->Result != 306)) // (Not part of HTTP/1.1, reserved) { - if (!Srv->Location.empty()) + if (Srv->Location.empty() == true); + else if (Srv->Location[0] == '/' && Queue->Uri.empty() == false) + { + URI Uri = Queue->Uri; + if (Uri.Host.empty() == false) + { + if (Uri.Port != 0) + strprintf(NextURI, "http://%s:%u", Uri.Host.c_str(), Uri.Port); + else + NextURI = "http://" + Uri.Host; + } + else + NextURI.clear(); + NextURI.append(Srv->Location); + return TRY_AGAIN_OR_REDIRECT; + } + else { NextURI = Srv->Location; return TRY_AGAIN_OR_REDIRECT; -- cgit v1.2.3-70-g09d2 From c34ea12ad509cb34c954ed574a301c3cbede55ec Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 10 May 2011 15:49:25 +0200 Subject: dequote URL taken from Location in redirects as we will otherwise quote an already quoted string in the request later (Closes: #602412) --- debian/changelog | 4 ++- methods/http.cc | 4 +-- test/integration/skip-bug-602412-dequote-redirect | 36 +++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100755 test/integration/skip-bug-602412-dequote-redirect (limited to 'methods') diff --git a/debian/changelog b/debian/changelog index fd10e0fcf..125fa7f70 100644 --- a/debian/changelog +++ b/debian/changelog @@ -50,8 +50,10 @@ apt (0.8.14.2) UNRELEASED; urgency=low use the method as a simple standalone downloader - Location header in redirects should be absolute URI, but some servers just send an absolute path so still deal with it properly + - dequote URL taken from Location in redirects as we will otherwise + quote an already quoted string in the request later (Closes: #602412) - -- David Kalnischkies Wed, 27 Apr 2011 17:37:58 +0200 + -- David Kalnischkies Tue, 10 May 2011 15:49:19 +0200 apt (0.8.14.1) unstable; urgency=low diff --git a/methods/http.cc b/methods/http.cc index d3e00553c..13f9cbe06 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -961,12 +961,12 @@ HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv) } else NextURI.clear(); - NextURI.append(Srv->Location); + NextURI.append(DeQuoteString(Srv->Location)); return TRY_AGAIN_OR_REDIRECT; } else { - NextURI = Srv->Location; + NextURI = DeQuoteString(Srv->Location); return TRY_AGAIN_OR_REDIRECT; } /* else pass through for error message */ diff --git a/test/integration/skip-bug-602412-dequote-redirect b/test/integration/skip-bug-602412-dequote-redirect new file mode 100755 index 000000000..a63d36246 --- /dev/null +++ b/test/integration/skip-bug-602412-dequote-redirect @@ -0,0 +1,36 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' + +if ! which lighttpd > /dev/null; then + msgdie 'You need lighttpd for this testcase, sorry…' + exit 1 +fi + +buildsimplenativepackage 'unrelated' 'all' '0.5~squeeze1' 'unstable' + +setupaptarchive + +echo "server.modules = ( \"mod_redirect\" ) +server.document-root = \"$(readlink -f ./aptarchive)\" +server.port = 8080 +server.stat-cache-engine = \"disable\" +url.redirect = ( \"^/pool/(.*)$\" => \"/newpool/\$1\" )" > lighttpd.conf + +mv aptarchive/pool aptarchive/newpool +lighttpd -t -f lighttpd.conf >/dev/null || msgdie 'Can not change to webserver: our lighttpd config is invalid' +lighttpd -D -f lighttpd.conf 2>/dev/null >/dev/null & +addtrap "kill $!;" + +local APTARCHIVE="file://$(readlink -f ./aptarchive)" +for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do + sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#" +done + +aptget update -qq || msgdie 'apt-get update failed' +aptget install unrelated --download-only -qq || msgdie 'downloading package failed' + -- cgit v1.2.3-70-g09d2