#include <config.h>
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/acquire-method.h>
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
// CircleBuf::CircleBuf - Circular input buffer /*{{{*/
// ---------------------------------------------------------------------
/* */
-CircleBuf::CircleBuf(unsigned long long Size)
- : Size(Size), Hash(0), TotalWriten(0)
+CircleBuf::CircleBuf(unsigned long long Size)
+ : Size(Size), Hash(NULL), TotalWriten(0)
{
Buf = new unsigned char[Size];
Reset();
TotalWriten = 0;
MaxGet = (unsigned long long)-1;
OutQueue = string();
- if (Hash != 0)
+ if (Hash != NULL)
{
delete Hash;
- Hash = new Hashes;
+ Hash = NULL;
}
}
/*}}}*/
TotalWriten += Res;
- if (Hash != 0)
+ if (Hash != NULL)
Hash->Add(Buf + (OutP%Size),Res);
OutP += Res;
{
/* Closes encoding is used when the server did not specify a size, the
loss of the connection means we are done */
- if (Persistent == false)
- In.Limit(-1);
- else if (JunkSize != 0)
+ if (JunkSize != 0)
In.Limit(JunkSize);
- else
- In.Limit(Size - StartPos);
+ else if (DownloadSize != 0)
+ In.Limit(DownloadSize);
+ else if (Persistent == false)
+ In.Limit(-1);
// Just transfer the whole block.
do
return (ServerFd != -1);
}
/*}}}*/
-bool HttpServerState::InitHashes(FileFd &File) /*{{{*/
+bool HttpServerState::InitHashes(HashStringList const &ExpectedHashes) /*{{{*/
{
delete In.Hash;
- In.Hash = new Hashes;
-
- // Set the expected size and read file for the hashes
- File.Truncate(StartPos);
- return In.Hash->AddFD(File, StartPos);
+ In.Hash = new Hashes(ExpectedHashes);
+ return true;
}
/*}}}*/
+
APT_PURE Hashes * HttpServerState::GetHashes() /*{{{*/
{
return In.Hash;
C.f. https://tools.ietf.org/wg/httpbis/trac/ticket/158 */
Req << "GET " << requesturi << " HTTP/1.1\r\n";
if (Uri.Port != 0)
- Req << "Host: " << ProperHost << ":" << Uri.Port << "\r\n";
+ Req << "Host: " << ProperHost << ":" << std::to_string(Uri.Port) << "\r\n";
else
Req << "Host: " << ProperHost << "\r\n";
Req << "Cache-Control: no-cache\r\n"
<< "Pragma: no-cache\r\n";
else if (Itm->IndexFile == true)
- Req << "Cache-Control: max-age=" << _config->FindI("Acquire::http::Max-Age",0) << "\r\n";
+ Req << "Cache-Control: max-age=" << std::to_string(_config->FindI("Acquire::http::Max-Age",0)) << "\r\n";
else if (_config->FindB("Acquire::http::No-Store",false) == true)
Req << "Cache-Control: no-store\r\n";
return true;
}
/*}}}*/
-ServerState * HttpMethod::CreateServerState(URI uri) /*{{{*/
+std::unique_ptr<ServerState> HttpMethod::CreateServerState(URI const &uri)/*{{{*/
{
- return new HttpServerState(uri, this);
+ return std::unique_ptr<ServerState>(new HttpServerState(uri, this));
}
/*}}}*/
void HttpMethod::RotateDNS() /*{{{*/