Downloader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 #include "XactionInitiator.h"
18 
19 class ClientHttpRequest;
20 class StoreIOBuffer;
21 class clientStreamNode;
24 
29 class Downloader: virtual public AsyncJob
30 {
32 public:
33 
35  class CbDialer: public CallDialer {
36  public:
37  CbDialer(): status(Http::scNone) {}
38  virtual ~CbDialer() {}
39 
40  /* CallDialer API */
41  virtual bool canDial(AsyncCall &call) = 0;
42  virtual void dial(AsyncCall &call) = 0;
43  virtual void print(std::ostream &os) const;
44 
47  };
48 
49  Downloader(SBuf &url, AsyncCall::Pointer &aCallback, const XactionInitiator initiator, unsigned int level = 0);
50  virtual ~Downloader();
51  virtual void swanSong();
52 
54  void downloadFinished();
55 
57  unsigned int nestedLevel() const {return level_;}
58 
60 
61 protected:
62 
63  /* AsyncJob API */
64  virtual bool doneAll() const;
65  virtual void start();
66 
67 private:
68 
69  bool buildRequest();
70  void callBack(Http::StatusCode const status);
71 
73  static const size_t MaxObjectSize = 1*1024*1024;
74 
78  const unsigned int level_;
81 
84 };
85 
86 #endif
87 
SBuf url_
the url to download
Definition: Downloader.h:75
Downloader(SBuf &url, AsyncCall::Pointer &aCallback, const XactionInitiator initiator, unsigned int level=0)
Definition: Downloader.cc:66
Definition: SBuf.h:87
virtual ~CbDialer()
Definition: Downloader.h:38
RefCount< DownloaderContext > DownloaderContextPointer
Definition: Downloader.h:22
virtual const char * status() const
internal cleanup; do not call directly
Definition: AsyncJob.cc:159
XactionInitiator initiator_
The initiator of the download request.
Definition: Downloader.h:80
static const size_t MaxObjectSize
The maximum allowed object size.
Definition: Downloader.h:73
virtual bool doneAll() const
whether positive goal has been reached
Definition: Downloader.cc:91
identifies a protocol agent or Squid feature initiating transactions
virtual void print(std::ostream &os) const
Definition: Downloader.cc:61
virtual void start()
called by AsyncStart; do not call directly
Definition: Downloader.cc:179
StatusCode
Definition: StatusCode.h:20
const unsigned int level_
Definition: Downloader.h:78
void handleReply(clientStreamNode *, ClientHttpRequest *, HttpReply *, StoreIOBuffer)
Definition: Downloader.cc:186
AsyncCall::Pointer callback_
callback to call when download finishes
Definition: Downloader.h:76
CBDATA_CLASS(Downloader)
Http::StatusCode status
Definition: Downloader.h:46
void callBack(Http::StatusCode const status)
Definition: Downloader.cc:254
virtual void swanSong()
Definition: Downloader.cc:81
unsigned int nestedLevel() const
The nested level of Downloader object (downloads inside downloads).
Definition: Downloader.h:57
virtual ~Downloader()
Definition: Downloader.cc:75
void downloadFinished()
delays destruction to protect doCallouts()
Definition: Downloader.cc:245
DownloaderContextPointer context_
Pointer to an object that stores the clientStream required info.
Definition: Downloader.h:83
virtual void dial(AsyncCall &call)=0
Callback data to use with Downloader callbacks.
Definition: Downloader.h:35
virtual bool canDial(AsyncCall &call)=0
SBuf object_
the object body data
Definition: Downloader.h:77
bool buildRequest()
Initializes and starts the HTTP GET request to the remote server.
Definition: Downloader.cc:127

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors