1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
/* -*- Mode: C++ -*-
* Worldvisions Weaver Software:
* Copyright (C) 1997-2002 Net Integration Technologies, Inc.
*
*/
#ifndef __WVHTTP_H
#define __WVHTTP_H
#include "wvurl.h"
#include "wvtcp.h"
#include "wvstreamclone.h"
#include "wvresolver.h"
#include "wvhashtable.h"
struct WvHTTPHeader
{
WvString name, value;
WvHTTPHeader(WvStringParm _name, WvStringParm _value)
: name(_name), value(_value)
{}
};
DeclareWvDict(WvHTTPHeader, WvString, name);
class WvSSLStream;
/**
* WvHTTPStream connects to an HTTP server and allows the requested file
* to be retrieved using the usual WvStream-style calls.
*/
class WvHTTPStream : public WvStreamClone
{
public:
enum State {Resolving = 0, Connecting, ReadHeader1, ReadHeader, ReadData,
Done};
WvHTTPHeaderDict headers;
WvHTTPHeaderDict client_headers;
size_t num_received;
WvTCPConn *tcp;
WvSSLStream *ssl;
WvStream *conn; // Can't use 'cloned' since it has no select()
/**
* Changed: now we copy _url in the constructor, so you can (and must)
* delete it whenever you want.
*/
WvHTTPStream(const WvURL &_url);
virtual bool isok() const;
virtual int geterr() const;
virtual WvString errstr() const;
virtual bool pre_select(SelectInfo &si);
virtual size_t uread(void *buf, size_t count);
public:
WvURL url;
State state;
};
#endif // __WVHTTP_H
|