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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors