From: David Kalnischkies
Date: Tue, 10 Jul 2012 22:46:27 +0000 (+0200)
Subject: ensure that directories are accessed with a slash at the end of the url
X-Git-Tag: 0.9.13.exp1ubuntu1~50^2~6
X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/64a28515923aa67a1d109a82aba1892cd227bb15?ds=sidebyside
ensure that directories are accessed with a slash at the end of the url
---
diff --git a/test/interactive-helper/aptwebserver.cc b/test/interactive-helper/aptwebserver.cc
index 920ab3bcc..2052fe6d8 100644
--- a/test/interactive-helper/aptwebserver.cc
+++ b/test/interactive-helper/aptwebserver.cc
@@ -146,6 +146,26 @@ void sendError(int const client, int const httpcode, std::string const &request,
sendData(client, response);
}
/*}}}*/
+void sendRedirect(int const client, int const httpcode, std::string const &uri, std::string const &request, bool content) { /*{{{*/
+ std::list headers;
+ std::string response("");
+ response.append(httpcodeToStr(httpcode)).append("");
+ response.append("").append(httpcodeToStr(httpcode)).append("
You should be redirected to ").append(uri).append("
");
+ response.append("This page is a result of the request: ");
+ response.append(request).append("
");
+ addDataHeaders(headers, response);
+ std::string location("Location: ");
+ if (strncmp(uri.c_str(), "http://", 7) != 0)
+ location.append("http://").append(LookupTag(request, "Host")).append("/").append(uri);
+ else
+ location.append(uri);
+ headers.push_back(location);
+ sendHead(client, httpcode, headers);
+ if (content == true)
+ sendData(client, response);
+}
+ /*}}}*/
// sendDirectoryLisiting /*{{{*/
int filter_hidden_files(const struct dirent *a) {
if (a->d_name[0] == '.')
@@ -209,12 +229,15 @@ void sendDirectoryListing(int const client, std::string const &dir, std::string
std::string filename(dir);
filename.append("/").append(namelist[i]->d_name);
stat(filename.c_str(), &fs);
- listing << "" << ((S_ISDIR(fs.st_mode)) ? 'd' : 'f') << " | "
- << "d_name << "\">" << namelist[i]->d_name << " | ";
- if (S_ISDIR(fs.st_mode))
- listing << "- | ";
- else
- listing << "" << SizeToStr(fs.st_size) << "B | ";
+ if (S_ISDIR(fs.st_mode)) {
+ listing << "
d | "
+ << "d_name << "/\">" << namelist[i]->d_name << " | "
+ << "- | ";
+ } else {
+ listing << "
f | "
+ << "d_name << "\">" << namelist[i]->d_name << " | "
+ << "" << SizeToStr(fs.st_size) << "B | ";
+ }
listing << "" << TimeRFC1123(fs.st_mtime) << " |
" << std::endl;
}
listing << "