15#include "wvistreamlist.h"
16#include "wvstreamclone.h"
18#include "wvhashtable.h"
19#include "wvbufstream.h"
28static const WvString DEFAULT_ANON_PW(
"weasels@");
34 WvHTTPHeader(WvStringParm _name, WvStringParm _value)
35 : name(_name), value(_value)
58 WvUrlRequest(WvStringParm _url, WvStringParm _method, WvStringParm _headers,
59 WvStream *content_source,
bool _create_dirs,
bool _pipeline_test);
73 WvUrlLink(WvStringParm _linkname, WvStringParm _url)
74 : linkname(_linkname), url(_url)
80class WvBufUrlStream :
public WvBufStream
90 WvHTTPHeaderDict headers;
92 WvBufUrlStream() : status(0), headers(10)
94 virtual ~WvBufUrlStream()
98 const char *wstype()
const {
return "WvBufUrlStream"; }
113 Target(
const WvIPPortAddr &_remaddr, WvStringParm _username)
114 : remaddr(_remaddr), username(_username) {}
118 bool operator== (
const Target &n2)
const
119 {
return (username == n2.username && remaddr == n2.remaddr); }
122 static int max_requests;
126 WvUrlRequestList urls, waiting_urls;
129 virtual void doneurl() = 0;
130 virtual void request_next() = 0;
133 WvUrlStream(
const WvIPPortAddr &_remaddr, WvStringParm _username,
134 WvStringParm logname)
136 log(logname,
WvLog::Debug)
148 virtual size_t remaining()
154 const char *wstype()
const {
return "WvUrlStream"; }
162class WvHttpStream :
public WvUrlStream
165 static bool global_enable_pipelining;
166 bool enable_pipelining;
169 int pipeline_test_count;
171 bool sent_url_request;
172 WvIPPortAddrTable &pipeline_incompatible;
173 WvString http_response, pipeline_test_response;
174 WvDynBuf putstream_data;
176 enum { Unknown, Chunked, ContentLength, Infinity,
177 PostHeadInfinity, PostHeadChunked, PostHeadStream,
178 ChuckInfinity, ChuckChunked, ChuckStream } encoding;
179 size_t bytes_remaining;
180 bool in_chunk_trailer, last_was_pipeline_test, in_doneurl;
182 virtual void doneurl();
183 virtual void request_next();
184 void start_pipeline_test(
WvUrl *url);
187 void pipelining_is_broken(
int why);
190 WvHttpStream(
const WvIPPortAddr &_remaddr, WvStringParm _username,
191 bool ssl, WvIPPortAddrTable &_pipeline_incompatible);
192 virtual ~WvHttpStream();
194 virtual void close();
198 virtual size_t remaining()
199 {
return bytes_remaining; }
202 const char *wstype()
const {
return "WvHttpStream"; }
206class WvFtpStream :
public WvUrlStream
208 bool logged_in, pasv_acked;
211 time_t last_request_time;
214 virtual void doneurl();
215 virtual void request_next();
219 char *get_important_line();
226 WvString parse_for_links(
char *line);
229 void* real_execute(
void*);
232 WvFtpStream(
const WvIPPortAddr &_remaddr, WvStringParm _username,
233 WvStringParm _password);
237 virtual void close();
241 const char *wstype()
const {
return "WvFtpStream"; }
246class WvHttpPool :
public WvIStreamList
250 WvUrlStreamDict conns;
251 WvUrlRequestList urls;
252 int num_streams_created;
255 WvIPPortAddrTable pipeline_incompatible;
259 virtual ~WvHttpPool();
265 WvBufUrlStream *addurl(WvStringParm _url, WvStringParm _method =
"GET",
266 WvStringParm _headers =
"",
268 bool create_dirs =
false);
279 {
return !urls.count(); }
282 const char *wstype()
const {
return "WvHttpPool"; }
WvCont provides "continuations", which are apparently also known as semi-coroutines.
virtual void close()
Close this stream.
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling select().
virtual bool post_select(SelectInfo &si)
post_select() is called after select(), and returns true if this object is now ready.
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling select().
virtual bool post_select(SelectInfo &si)
post_select() is called after select(), and returns true if this object is now ready.
virtual void pre_select(SelectInfo &si)
pre_select() sets up for eventually calling select().
virtual bool post_select(SelectInfo &si)
post_select() is called after select(), and returns true if this object is now ready.
virtual void close()
Close this stream.
virtual void execute()
The callback() function calls execute(), and then calls the user- specified callback if one is define...
An IP+Port address also includes a port number, with the resulting form www.xxx.yyy....
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
ASynchronous DNS resolver functions, so that we can do non-blocking lookups.
WvStreamClone(IWvStream *_cloned=NULL)
Constructs the stream, then calls setclone(_cloned).
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
WvStream()
Basic constructor for just a do-nothing WvStream.
WvString is an implementation of a simple and efficient printable-string class.
WvTCPConn tries to make all outgoing connections asynchronously (in the background).
virtual void close()=0
Close this stream.
virtual void execute()=0
The callback() function calls execute(), and then calls the user- specified callback if one is define...
the data structure used by pre_select()/post_select() and internally by select().