Added HTTP::Downloader class
This commit is contained in:
parent
72a6816ec1
commit
74acdedeb2
5 changed files with 148 additions and 2 deletions
27
lib/downloader.h
Normal file
27
lib/downloader.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include "http_parser.h"
|
||||
#include "socket.h"
|
||||
|
||||
namespace HTTP{
|
||||
class Downloader{
|
||||
public:
|
||||
Downloader(){progressCallback = 0;}
|
||||
std::string &data();
|
||||
bool get(const std::string &link);
|
||||
bool get(const HTTP::URL &link, uint8_t maxRecursiveDepth = 6);
|
||||
std::string getHeader(const std::string &headerName);
|
||||
std::string &getStatusText();
|
||||
uint32_t getStatusCode();
|
||||
bool isOk();
|
||||
bool (*progressCallback)(); ///< Called every time the socket stalls, up to 4X per second.
|
||||
void setHeader(const std::string &name, const std::string &val);
|
||||
void clearHeaders();
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> extraHeaders; ///< Holds extra headers to sent with request
|
||||
std::string connectedHost; ///< Currently connected host name
|
||||
uint32_t connectedPort; ///< Currently connected port number
|
||||
Parser H; ///< HTTP parser for downloader
|
||||
Socket::Connection S; ///< TCP socket for downloader
|
||||
};
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue