apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

BaseHttpMethod Class Referenceabstract

#include <basehttp.h>

Inheritance diagram for BaseHttpMethod:
Collaboration diagram for BaseHttpMethod:

Public Types

enum  DealWithHeadersResult {
 Result of the header parsing. More...
- Public Types inherited from pkgAcqMethod
enum  CnfFlags {
  SingleInstance = (1 << 0) , Pipeline = (1 << 1) , SendConfig = (1 << 2) , LocalOnly = (1 << 3) ,
  NeedsCleanup = (1 << 4) , Removable = (1 << 5) , AuxRequests = (1 << 6) , SendURIEncoded = (1 << 7)

Public Member Functions

virtual DealWithHeadersResult DealWithHeaders (FetchResult &Res, RequestState &Req)
 Handle the retrieved header data. More...
int Loop ()
virtual void SendReq (FetchItem *Itm)=0
virtual std::unique_ptr< ServerStateCreateServerState (URI const &uri)=0
virtual void RotateDNS ()=0
virtual bool Configuration (std::string Message) APT_OVERRIDE
bool AddProxyAuth (URI &Proxy, URI const &Server)
 BaseHttpMethod (std::string &&Binary, char const *const Ver, unsigned long const Flags)
virtual ~BaseHttpMethod ()
- Public Member Functions inherited from aptAuthConfMethod
bool MaybeAddAuthTo (URI &uri)
 aptAuthConfMethod (std::string &&Binary, char const *const Ver, unsigned long const Flags) APT_NONNULL(3)
- Public Member Functions inherited from aptMethod
bool RunningInQemu (void)
bool LoadSeccomp ()
bool CalculateHashes (FetchItem const *const Itm, FetchResult &Res) const APT_NONNULL(2)
void Warning (std::string &&msg)
void setPostfixForMethodNames (char const *const postfix) APT_NONNULL(2)
bool DebugEnabled () const
std::string ConfigFind (char const *const postfix, std::string const &defValue) const APT_NONNULL(2)
std::string ConfigFind (std::string const &postfix, std::string const &defValue) const
bool ConfigFindB (char const *const postfix, bool const defValue) const APT_NONNULL(2)
int ConfigFindI (char const *const postfix, int const defValue) const APT_NONNULL(2)
bool TransferModificationTimes (char const *const From, char const *const To, time_t &LastModified) APT_NONNULL(2
 if (lstat(To, &Buf2) !=0||S_ISLNK(Buf2.st_mode)) return true
 if (stat(From, &Buf) !=0) return _error -> Errno("stat", _("Failed to stat"))
 if (utimes(To, times) !=0) return _error -> Errno("utimes", _("Failed to set modification time"))
void Dequeue ()
 aptMethod (std::string &&Binary, char const *const Ver, unsigned long const Flags) APT_NONNULL(3)
- Public Member Functions inherited from pkgAcqMethod
void Log (const char *Format,...)
void Status (const char *Format,...)
void Redirect (const std::string &NewURI)
int Run (bool Single=false)
void SetFailReason (std::string Msg)
void SetIP (std::string aIP)
 pkgAcqMethod (const char *Ver, unsigned long Flags=0)
virtual ~pkgAcqMethod ()
void DropPrivsOrDie ()

Static Public Member Functions

static APT_NORETURN void SigTerm (int)
- Static Public Member Functions inherited from aptMethod
static std::string URIEncode (std::string const &part)
static std::string DecodeSendURI (std::string const &part)

Public Attributes

bool Debug
unsigned long PipelineDepth
- Public Attributes inherited from aptMethod
std::vector< std::string > methodNames
bool struct stat Buf2
struct stat Buf
struct timeval times [2]
times[0] tv_sec = Buf.st_atime
 LastModified = times[1].tv_sec = Buf.st_mtime
times[0] tv_usec = times[1].tv_usec = 0
return true

Static Public Attributes

static std::string FailFile
static int FailFd = -1
static time_t FailTime = 0

Protected Member Functions

virtual bool Fetch (FetchItem *) APT_OVERRIDE
unsigned long long FindMaximumObjectSizeInQueue () const APT_PURE
- Protected Member Functions inherited from pkgAcqMethod
virtual bool URIAcquire (std::string const &, FetchItem *Itm)
void Fail (bool Transient=false)
void Fail (const char *Why, bool Transient=false)
virtual void Fail (std::string Why, bool Transient=false)
virtual void URIStart (FetchResult &Res)
virtual void URIDone (FetchResult &Res, FetchResult *Alt=0)
void SendMessage (std::string const &header, std::unordered_map< std::string, std::string > &&fields)
bool MediaFail (std::string Required, std::string Drive)
virtual void Exit ()
 APT_DEPRECATED_MSG ("Use SendMessage instead") void PrintStatus(char const *const header

Protected Attributes

std::unique_ptr< ServerStateServer
std::string NextURI
bool AllowRedirect
- Protected Attributes inherited from aptMethod
std::string const Binary
unsigned long SeccompFlags
- Protected Attributes inherited from pkgAcqMethod
std::vector< std::string > Messages
std::string FailReason
std::string UsedMirror
std::string IP
const char * Format
const char va_list &args const

Additional Inherited Members

- Protected Types inherited from aptMethod
enum  Seccomp { BASE = (1 << 1) , NETWORK = (1 << 2) , DIRECTORY = (1 << 3) }

Detailed Description

Definition at line 118 of file basehttp.h.

Member Enumeration Documentation

◆ DealWithHeadersResult

Result of the header parsing.


The file is open and ready.


We got a IMS hit, the file has not changed.


The server reported a unrecoverable error.


The server reported a error with a error content page.


An error on the client side.


A redirect or retry request.

Definition at line 137 of file basehttp.h.

Constructor & Destructor Documentation

◆ BaseHttpMethod()

BaseHttpMethod ( std::string &&  Binary,
char const *const  Ver,
unsigned long const  Flags 

Definition at line 893 of file basehttp.cc.

◆ ~BaseHttpMethod()

virtual ~BaseHttpMethod ( )

Definition at line 170 of file basehttp.h.

Member Function Documentation

◆ AddProxyAuth()

bool AddProxyAuth ( URI Proxy,
URI const Server 

◆ Configuration()

bool Configuration ( std::string  Message)

Reimplemented from aptAuthConfMethod.

Definition at line 899 of file basehttp.cc.

References _config, and aptAuthConfMethod::Configuration().

◆ CreateServerState()

virtual std::unique_ptr<ServerState> CreateServerState ( URI const uri)
pure virtual

Implemented in HttpMethod.

Referenced by Loop().

◆ DealWithHeaders()

◆ Fetch()

◆ FindMaximumObjectSizeInQueue()

unsigned long long FindMaximumObjectSizeInQueue ( ) const

Definition at line 881 of file basehttp.cc.

References I, pkgAcqMethod::Queue, and pkgAcqMethod::QueueBack.

Referenced by Loop().

◆ Loop()

int Loop ( )

Definition at line 566 of file basehttp.cc.

References _config, URI::Access, AllowRedirect, FileFd::Close(), aptMethod::ConfigFindB(), aptMethod::ConfigFindI(), CreateServerState(), RequestState::Date, DealWithHeaders(), Debug, aptMethod::DebugEnabled(), pkgAcqMethod::FetchItem::DestFile, RequestState::DownloadSize, ERROR_NOT_FROM_SERVER, ERROR_UNRECOVERABLE, ERROR_WITH_CONTENT_PAGE, pkgAcqMethod::FetchItem::ExpectedHashes, pkgAcqMethod::Fail(), FailFd, pkgAcqMethod::FailReason, FATAL_ERROR, Fetch(), RequestState::File, FILE_IS_OPEN, pkgAcqMethod::FetchResult::Filename, HashStringList::FileSize(), FindMaximumObjectSizeInQueue(), Hashes::GetHashStringList(), RequestState::HaveContent, URI::Host, I, IMS_HIT, RequestState::MaximumSize, msg, pkgAcqMethod::FetchItem::Next, NextURI, PipelineDepth, pkgAcqMethod::FetchItem::Proxy(), pkgAcqMethod::Queue, pkgAcqMethod::QueueBack, pkgAcqMethod::Redirect(), Rename(), RequestState::Result, RotateDNS(), pkgAcqMethod::Run(), ServerState::RUN_HEADERS_IO_ERROR, ServerState::RUN_HEADERS_OK, ServerState::RUN_HEADERS_PARSE_ERROR, Server, pkgAcqMethod::SetFailReason(), aptMethod::setPostfixForMethodNames(), SigTerm(), pkgAcqMethod::FetchResult::Size, FileFd::Size(), RequestState::StartPos, strprintf(), SUCCESSFUL, pkgAcqMethod::FetchResult::TakeHashes(), aptMethod::times, TRANSIENT_ERROR, TRY_AGAIN_OR_REDIRECT, pkgAcqMethod::FetchItem::Uri, pkgAcqMethod::URIDone(), pkgAcqMethod::URIStart(), HashStringList::usable(), WaitFd(), and aptMethod::Warning().

Referenced by main().

◆ RotateDNS()

virtual void RotateDNS ( )
pure virtual

Implemented in HttpMethod.

Referenced by Loop().

◆ SendReq()

virtual void SendReq ( FetchItem Itm)
pure virtual

Implemented in HttpMethod.

Referenced by Fetch().

◆ SigTerm()

void SigTerm ( int  )

Definition at line 479 of file basehttp.cc.

References FailFd, FailFile, FailTime, and aptMethod::times.

Referenced by Loop().

Member Data Documentation

◆ AllowRedirect

bool AllowRedirect

Definition at line 126 of file basehttp.h.

Referenced by DealWithHeaders(), and Loop().

◆ Debug

bool Debug

◆ FailFd

int FailFd = -1

Definition at line 156 of file basehttp.h.

Referenced by HttpMethod::DealWithHeaders(), Loop(), and SigTerm().

◆ FailFile

string FailFile

Definition at line 155 of file basehttp.h.

Referenced by HttpMethod::DealWithHeaders(), and SigTerm().

◆ FailTime

time_t FailTime = 0

Definition at line 157 of file basehttp.h.

Referenced by HttpMethod::DealWithHeaders(), and SigTerm().

◆ NextURI

std::string NextURI

Definition at line 124 of file basehttp.h.

Referenced by DealWithHeaders(), and Loop().

◆ PipelineDepth

unsigned long PipelineDepth

Definition at line 134 of file basehttp.h.

Referenced by Fetch(), and Loop().

◆ Server

std::unique_ptr<ServerState> Server

The documentation for this class was generated from the following files: