diff options
author | David Kalnischkies <david@kalnischkies.de> | 2017-10-27 18:39:36 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2018-01-03 18:55:41 +0100 |
commit | 57fa854e4cdb060e87ca265abd5a83364f9fa681 (patch) | |
tree | f360e6166d8c5352e3954a0c9129b57a3dcfaf69 /methods/http.cc | |
parent | ef9677831f62a1554a888ebc7b162517d7881116 (diff) |
reimplement and simplify mirror:// method
Embedding an entire acquire stack and HTTP logic in the mirror method
made it rather heavy weight and fragile. This reimplement goes the other
way by doing only the bare minimum in the method itself and instead
redirect the actual download of files to their proper methods.
The reimplementation drops the (in the real world) unused query-string
feature as it isn't really implementable in the new architecture.
Diffstat (limited to 'methods/http.cc')
-rw-r--r-- | methods/http.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/methods/http.cc b/methods/http.cc index 2d23b1646..5d286bcb4 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -31,6 +31,7 @@ #include <sstream> #include <arpa/inet.h> #include <errno.h> +#include <signal.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> @@ -1034,7 +1035,7 @@ BaseHttpMethod::DealWithHeadersResult HttpMethod::DealWithHeaders(FetchResult &R return FILE_IS_OPEN; } /*}}}*/ -HttpMethod::HttpMethod(std::string &&pProg) : BaseHttpMethod(pProg.c_str(), "1.2", Pipeline | SendConfig)/*{{{*/ +HttpMethod::HttpMethod(std::string &&pProg) : BaseHttpMethod(std::move(pProg), "1.2", Pipeline | SendConfig) /*{{{*/ { SeccompFlags = aptMethod::BASE | aptMethod::NETWORK; @@ -1051,3 +1052,14 @@ HttpMethod::HttpMethod(std::string &&pProg) : BaseHttpMethod(pProg.c_str(), "1.2 } } /*}}}*/ + +int main(int, const char *argv[]) +{ + // ignore SIGPIPE, this can happen on write() if the socket + // closes the connection (this is dealt with via ServerDie()) + signal(SIGPIPE, SIG_IGN); + std::string Binary = flNotDir(argv[0]); + if (Binary.find('+') == std::string::npos && Binary != "https" && Binary != "http") + Binary.append("+http"); + return HttpMethod(std::move(Binary)).Loop(); +} |