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_SRC_DOWNLOADER_H
10 #define SQUID_SRC_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 
19 class ClientHttpRequest;
20 class StoreIOBuffer;
21 class clientStreamNode;
24 class MasterXaction;
26 
29 public:
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 
39 std::ostream &operator <<(std::ostream &, const DownloaderAnswer &);
40 
45 class Downloader: virtual public AsyncJob
46 {
48 public:
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 
63 protected:
64 
65  /* AsyncJob API */
66  bool doneAll() const override;
67  void start() override;
68 
69 private:
70 
71  bool buildRequest();
72  void callBack(Http::StatusCode const status);
73 
75  static const size_t MaxObjectSize = 1*1024*1024;
76 
78 
81 
83  const unsigned int level_;
85 
88 };
89 
90 #endif /* SQUID_SRC_DOWNLOADER_H */
91 
const unsigned int level_
holds the nested downloads level
Definition: Downloader.h:83
@ scNone
Definition: StatusCode.h:21
Downloader(const SBuf &url, const AsyncCallback< Answer > &, const MasterXactionPointer &, unsigned int level=0)
Definition: Downloader.cc:71
void start() override
called by AsyncStart; do not call directly
Definition: Downloader.cc:185
MasterXactionPointer masterXaction_
download transaction context
Definition: Downloader.h:84
Definition: SBuf.h:93
a smart AsyncCall pointer for delivery of future results
void swanSong() override
Definition: Downloader.cc:86
StatusCode
Definition: StatusCode.h:20
void downloadFinished()
delays destruction to protect doCallouts()
Definition: Downloader.cc:251
Http::StatusCode outcome
Definition: Downloader.h:36
AsyncCallback< Answer > callback_
answer destination
Definition: Downloader.h:80
CBDATA_CHILD(Downloader)
SBuf url_
the url to download
Definition: Downloader.h:77
void handleReply(clientStreamNode *, ClientHttpRequest *, HttpReply *, StoreIOBuffer)
Definition: Downloader.cc:192
virtual const char * status() const
internal cleanup; do not call directly
Definition: AsyncJob.cc:182
void callBack(Http::StatusCode const status)
Definition: Downloader.cc:260
unsigned int nestedLevel() const
The nested level of Downloader object (downloads inside downloads).
Definition: Downloader.h:59
~Downloader() override
Definition: Downloader.cc:80
bool buildRequest()
Initializes and starts the HTTP GET request to the remote server.
Definition: Downloader.cc:136
DownloaderContextPointer context_
Pointer to an object that stores the clientStream required info.
Definition: Downloader.h:87
static const size_t MaxObjectSize
The maximum allowed object size.
Definition: Downloader.h:75
std::ostream & operator<<(std::ostream &, const DownloaderAnswer &)
Definition: Downloader.cc:63
bool doneAll() const override
whether positive goal has been reached
Definition: Downloader.cc:100
RefCount< DownloaderContext > DownloaderContextPointer
Definition: Downloader.h:22
download result
Definition: Downloader.h:28
SBuf object_
the object body data
Definition: Downloader.h:82

 

Introduction

Documentation

Support

Miscellaneous