summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
Diffstat (limited to 'methods')
-rw-r--r--methods/http.cc7
-rw-r--r--methods/http.h2
-rw-r--r--methods/https.cc5
-rw-r--r--methods/server.cc25
-rw-r--r--methods/server.h4
5 files changed, 26 insertions, 17 deletions
diff --git a/methods/http.cc b/methods/http.cc
index 0358b50cd..8d34aa6e3 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -647,6 +647,13 @@ bool HttpServerState::InitHashes(HashStringList const &ExpectedHashes) /*{{{*/
return true;
}
/*}}}*/
+void HttpServerState::Reset(bool const Everything) /*{{{*/
+{
+ ServerState::Reset(Everything);
+ if (Everything)
+ ServerFd = -1;
+}
+ /*}}}*/
APT_PURE Hashes * HttpServerState::GetHashes() /*{{{*/
{
diff --git a/methods/http.h b/methods/http.h
index 644e576f0..b7341f5f8 100644
--- a/methods/http.h
+++ b/methods/http.h
@@ -103,7 +103,7 @@ struct HttpServerState: public ServerState
virtual bool WriteResponse(std::string const &Data) APT_OVERRIDE;
public:
- virtual void Reset() APT_OVERRIDE { ServerState::Reset(); ServerFd = -1; };
+ virtual void Reset(bool const Everything = true) APT_OVERRIDE;
virtual bool RunData(FileFd * const File) APT_OVERRIDE;
virtual bool RunDataToDevNull() APT_OVERRIDE;
diff --git a/methods/https.cc b/methods/https.cc
index 283126f6b..c86f9407e 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -399,7 +399,10 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
// go for it - if the file exists, append on it
File = new FileFd(Itm->DestFile, FileFd::WriteAny);
- Server = CreateServerState(Itm->Uri);
+ if (Server == nullptr || Server->Comp(Itm->Uri) == false)
+ Server = CreateServerState(Itm->Uri);
+ else
+ Server->Reset(false);
if (Server->InitHashes(Itm->ExpectedHashes) == false)
return false;
diff --git a/methods/server.cc b/methods/server.cc
index 3f0e88457..d0b6ef3d7 100644
--- a/methods/server.cc
+++ b/methods/server.cc
@@ -46,20 +46,9 @@ time_t ServerMethod::FailTime = 0;
ServerState::RunHeadersResult ServerState::RunHeaders(FileFd * const File,
const std::string &Uri)
{
- State = Header;
-
+ Reset(false);
Owner->Status(_("Waiting for headers"));
- Major = 0;
- Minor = 0;
- Result = 0;
- TotalFileSize = 0;
- JunkSize = 0;
- StartPos = 0;
- Encoding = Closes;
- HaveContent = false;
- time(&Date);
-
do
{
string Data;
@@ -254,6 +243,18 @@ bool ServerState::AddPartialFileToHashes(FileFd &File) /*{{{*/
return GetHashes()->AddFD(File, StartPos);
}
/*}}}*/
+void ServerState::Reset(bool const Everything) /*{{{*/
+{
+ Major = 0; Minor = 0; Result = 0; Code[0] = '\0';
+ TotalFileSize = 0; JunkSize = 0; StartPos = 0;
+ Encoding = Closes; time(&Date); HaveContent = false;
+ State = Header; MaximumSize = 0;
+ if (Everything)
+ {
+ Persistent = false; Pipeline = false; PipelineAllowed = true;
+ }
+}
+ /*}}}*/
// ServerMethod::DealWithHeaders - Handle the retrieved header data /*{{{*/
// ---------------------------------------------------------------------
diff --git a/methods/server.h b/methods/server.h
index 1d114354f..63acceae6 100644
--- a/methods/server.h
+++ b/methods/server.h
@@ -84,9 +84,7 @@ struct ServerState
bool AddPartialFileToHashes(FileFd &File);
bool Comp(URI Other) const {return Other.Host == ServerName.Host && Other.Port == ServerName.Port;};
- virtual void Reset() {Major = 0; Minor = 0; Result = 0; Code[0] = '\0'; TotalFileSize = 0; JunkSize = 0;
- StartPos = 0; Encoding = Closes; time(&Date); HaveContent = false;
- State = Header; Persistent = false; Pipeline = false; MaximumSize = 0; PipelineAllowed = true;};
+ virtual void Reset(bool const Everything = true);
virtual bool WriteResponse(std::string const &Data) = 0;
/** \brief Transfer the data from the socket */