Downloader.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_DOWNLOADER_H
10#define SQUID_DOWNLOADER_H
11
12#include "base/AsyncCallbacks.h"
13#include "base/AsyncJob.h"
14#include "defines.h"
15#include "http/forward.h"
16#include "http/StatusCode.h"
17#include "sbuf/SBuf.h"
18
20class StoreIOBuffer;
24class MasterXaction;
26
29public:
30 // The content of a successfully received HTTP 200 OK reply to our GET request.
31 // Unused unless outcome is Http::scOkay.
33
37};
38
39std::ostream &operator <<(std::ostream &, const DownloaderAnswer &);
40
45class Downloader: virtual public AsyncJob
46{
48public:
50
51 Downloader(const SBuf &url, const AsyncCallback<Answer> &, const MasterXactionPointer &, unsigned int level = 0);
52 ~Downloader() override;
53 void swanSong() override;
54
56 void downloadFinished();
57
59 unsigned int nestedLevel() const {return level_;}
60
62
63protected:
64
65 /* AsyncJob API */
66 bool doneAll() const override;
67 void start() override;
68
69private:
70
71 bool buildRequest();
73
75 static const size_t MaxObjectSize = 1*1024*1024;
76
78
81
83 const unsigned int level_;
85
88};
89
90#endif
91
RefCount< DownloaderContext > DownloaderContextPointer
Definition: Downloader.h:23
std::ostream & operator<<(std::ostream &, const DownloaderAnswer &)
Definition: Downloader.cc:62
a smart AsyncCall pointer for delivery of future results
virtual const char * status() const
internal cleanup; do not call directly
Definition: AsyncJob.cc:182
download result
Definition: Downloader.h:28
Http::StatusCode outcome
Definition: Downloader.h:36
void callBack(Http::StatusCode const status)
Definition: Downloader.cc:259
AsyncCallback< Answer > callback_
answer destination
Definition: Downloader.h:80
~Downloader() override
Definition: Downloader.cc:79
void downloadFinished()
delays destruction to protect doCallouts()
Definition: Downloader.cc:250
bool doneAll() const override
whether positive goal has been reached
Definition: Downloader.cc:99
CBDATA_CHILD(Downloader)
void start() override
called by AsyncStart; do not call directly
Definition: Downloader.cc:184
SBuf url_
the url to download
Definition: Downloader.h:77
unsigned int nestedLevel() const
The nested level of Downloader object (downloads inside downloads).
Definition: Downloader.h:59
const unsigned int level_
holds the nested downloads level
Definition: Downloader.h:83
static const size_t MaxObjectSize
The maximum allowed object size.
Definition: Downloader.h:75
Downloader(const SBuf &url, const AsyncCallback< Answer > &, const MasterXactionPointer &, unsigned int level=0)
Definition: Downloader.cc:70
DownloaderContextPointer context_
Pointer to an object that stores the clientStream required info.
Definition: Downloader.h:87
MasterXactionPointer masterXaction_
download transaction context
Definition: Downloader.h:84
bool buildRequest()
Initializes and starts the HTTP GET request to the remote server.
Definition: Downloader.cc:135
SBuf object_
the object body data
Definition: Downloader.h:82
void swanSong() override
Definition: Downloader.cc:85
void handleReply(clientStreamNode *, ClientHttpRequest *, HttpReply *, StoreIOBuffer)
Definition: Downloader.cc:191
Definition: SBuf.h:94
StatusCode
Definition: StatusCode.h:20
@ scNone
Definition: StatusCode.h:21

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors