mirror of
https://github.com/ukui/apt.git
synced 2026-03-09 09:35:45 -07:00
report https download start only if we really get it
Reporting it via progress means that e.g. a redirect will trigger it, too, so you get a Get & Hit while http only reports a Hit as it should be.
This commit is contained in:
+2
-1
@@ -75,6 +75,8 @@ HttpsMethod::write_data(void *buffer, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
HttpsMethod *me = (HttpsMethod *)userp;
|
||||
|
||||
if (me->Res.Size == 0)
|
||||
me->URIStart(me->Res);
|
||||
if(me->File->Write(buffer, size*nmemb) != true)
|
||||
return false;
|
||||
|
||||
@@ -88,7 +90,6 @@ HttpsMethod::progress_callback(void *clientp, double dltotal, double dlnow,
|
||||
HttpsMethod *me = (HttpsMethod *)clientp;
|
||||
if(dltotal > 0 && me->Res.Size == 0) {
|
||||
me->Res.Size = (unsigned long long)dltotal;
|
||||
me->URIStart(me->Res);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -15,15 +15,24 @@ changetowebserver -o aptwebserver::redirect::replace::/pool/=/newpool/ \
|
||||
mv aptarchive/pool aptarchive/newpool
|
||||
mv aptarchive/dists aptarchive/newdists
|
||||
|
||||
msgtest 'Test redirection works in' 'apt-get update'
|
||||
testsuccess --nomsg aptget update
|
||||
testrun() {
|
||||
msgtest 'Test redirection works in' 'apt-get update'
|
||||
testsuccess --nomsg aptget update
|
||||
|
||||
# check that I-M-S header is kept in redirections
|
||||
testequal 'Hit http://localhost:8080 unstable InRelease
|
||||
Hit http://localhost:8080 unstable/main Sources
|
||||
Hit http://localhost:8080 unstable/main amd64 Packages
|
||||
Hit http://localhost:8080 unstable/main Translation-en
|
||||
Reading package lists...' aptget update #-o debug::pkgacquire=1 -o debug::pkgacquire::worker=1
|
||||
# check that I-M-S header is kept in redirections
|
||||
testequal "Hit $1 unstable InRelease
|
||||
Hit $1 unstable/main Sources
|
||||
Hit $1 unstable/main amd64 Packages
|
||||
Hit $1 unstable/main Translation-en
|
||||
Reading package lists..." aptget update
|
||||
|
||||
msgtest 'Test redirection works in' 'package download'
|
||||
testsuccess --nomsg aptget install unrelated --download-only -y
|
||||
msgtest 'Test redirection works in' 'package download'
|
||||
testsuccess --nomsg aptget install unrelated --download-only -y
|
||||
}
|
||||
|
||||
testrun 'http://localhost:8080'
|
||||
|
||||
rm -rf rootdir/var/lib/apt/lists rootdir/var/cache/apt/archives
|
||||
changetohttpswebserver
|
||||
|
||||
testrun 'https://localhost:4433'
|
||||
|
||||
@@ -197,9 +197,14 @@ void sendRedirect(int const client, int const httpcode, std::string const &uri,/
|
||||
response.append(request).append("</pre></body></html>");
|
||||
addDataHeaders(headers, response);
|
||||
std::string location("Location: ");
|
||||
if (strncmp(uri.c_str(), "http://", 7) != 0)
|
||||
if (strncmp(uri.c_str(), "http://", 7) != 0 && strncmp(uri.c_str(), "https://", 8) != 0)
|
||||
{
|
||||
location.append("http://").append(LookupTag(request, "Host")).append("/");
|
||||
std::string const host = LookupTag(request, "Host");
|
||||
if (host.find(":4433") != std::string::npos)
|
||||
location.append("https://");
|
||||
else
|
||||
location.append("http://");
|
||||
location.append(host).append("/");
|
||||
if (strncmp("/home/", uri.c_str(), strlen("/home/")) == 0 && uri.find("/public_html/") != std::string::npos)
|
||||
{
|
||||
std::string homeuri = SubstVar(uri, "/home/", "~");
|
||||
@@ -507,7 +512,8 @@ void * handleClient(void * voidclient) /*{{{*/
|
||||
std::string redirect = "/" + filename;
|
||||
for (::Configuration::Item *I = Replaces->Child; I != NULL; I = I->Next)
|
||||
redirect = SubstVar(redirect, I->Tag, I->Value);
|
||||
redirect.erase(0,1);
|
||||
if (redirect.empty() == false && redirect[0] == '/')
|
||||
redirect.erase(0,1);
|
||||
if (redirect != filename)
|
||||
{
|
||||
sendRedirect(client, 301, redirect, *m, sendContent);
|
||||
@@ -542,7 +548,13 @@ void * handleClient(void * voidclient) /*{{{*/
|
||||
}
|
||||
|
||||
// deal with the request
|
||||
if (RealFileExists(filename) == true)
|
||||
if (_config->FindB("aptwebserver::support::http", true) == false &&
|
||||
LookupTag(*m, "Host").find(":4433") == std::string::npos)
|
||||
{
|
||||
sendError(client, 400, *m, sendContent, "HTTP disabled, all requests must be HTTPS");
|
||||
continue;
|
||||
}
|
||||
else if (RealFileExists(filename) == true)
|
||||
{
|
||||
FileFd data(filename, FileFd::ReadOnly);
|
||||
std::string condition = LookupTag(*m, "If-Modified-Since", "");
|
||||
|
||||
Reference in New Issue
Block a user