Downloader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2022 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/AsyncJob.h"
13 #include "defines.h"
14 #include "http/forward.h"
15 #include "http/StatusCode.h"
16 #include "sbuf/SBuf.h"
17 
18 class ClientHttpRequest;
19 class StoreIOBuffer;
20 class clientStreamNode;
21 class DownloaderContext;
23 class MasterXaction;
25 
30 class Downloader: virtual public AsyncJob
31 {
33 public:
34 
36  class CbDialer: public CallDialer {
37  public:
39  virtual ~CbDialer() {}
40 
41  /* CallDialer API */
42  virtual bool canDial(AsyncCall &call) = 0;
43  virtual void dial(AsyncCall &call) = 0;
44  virtual void print(std::ostream &os) const;
45 
48  };
49 
50  Downloader(const SBuf &url, const AsyncCall::Pointer &aCallback, const MasterXactionPointer &, unsigned int level = 0);
51  virtual ~Downloader();
52  virtual void swanSong();
53 
55  void downloadFinished();
56 
58  unsigned int nestedLevel() const {return level_;}
59 
61 
62 protected:
63 
64  /* AsyncJob API */
65  virtual bool doneAll() const;
66  virtual void start();
67 
68 private:
69 
70  bool buildRequest();
71  void callBack(Http::StatusCode const status);
72 
74  static const size_t MaxObjectSize = 1*1024*1024;
75 
79  const unsigned int level_;
81 
84 };
85 
86 #endif
87 
const unsigned int level_
holds the nested downloads level
Definition: Downloader.h:79
virtual bool doneAll() const
whether positive goal has been reached
Definition: Downloader.cc:96
@ scNone
Definition: StatusCode.h:21
virtual bool canDial(AsyncCall &call)=0
MasterXactionPointer masterXaction_
download transaction context
Definition: Downloader.h:80
Definition: SBuf.h:87
virtual void dial(AsyncCall &call)=0
StatusCode
Definition: StatusCode.h:20
Definition: forward.h:22
CBDATA_CLASS(Downloader)
virtual void start()
called by AsyncStart; do not call directly
Definition: Downloader.cc:181
Http::StatusCode status
Definition: Downloader.h:47
void downloadFinished()
delays destruction to protect doCallouts()
Definition: Downloader.cc:247
virtual void print(std::ostream &os) const
Definition: Downloader.cc:62
AsyncCall::Pointer callback_
callback to call when download finishes
Definition: Downloader.h:77
Downloader(const SBuf &url, const AsyncCall::Pointer &aCallback, const MasterXactionPointer &, unsigned int level=0)
Definition: Downloader.cc:67
virtual void swanSong()
Definition: Downloader.cc:82
virtual ~CbDialer()
Definition: Downloader.h:39
virtual ~Downloader()
Definition: Downloader.cc:76
SBuf url_
the url to download
Definition: Downloader.h:76
void handleReply(clientStreamNode *, ClientHttpRequest *, HttpReply *, StoreIOBuffer)
Definition: Downloader.cc:188
virtual const char * status() const
internal cleanup; do not call directly
Definition: AsyncJob.cc:167
void callBack(Http::StatusCode const status)
Definition: Downloader.cc:256
unsigned int nestedLevel() const
The nested level of Downloader object (downloads inside downloads).
Definition: Downloader.h:58
bool buildRequest()
Initializes and starts the HTTP GET request to the remote server.
Definition: Downloader.cc:132
DownloaderContextPointer context_
Pointer to an object that stores the clientStream required info.
Definition: Downloader.h:83
static const size_t MaxObjectSize
The maximum allowed object size.
Definition: Downloader.h:74
RefCount< DownloaderContext > DownloaderContextPointer
Definition: Downloader.h:21
Callback data to use with Downloader callbacks.
Definition: Downloader.h:36
SBuf object_
the object body data
Definition: Downloader.h:78

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors