2014-01-30 07:28:07 +04:00
|
|
|
#ifndef UTIL_H
|
|
|
|
#define UTIL_H
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2014-12-23 05:20:39 +03:00
|
|
|
#include <iostream>
|
2014-10-31 21:17:52 +03:00
|
|
|
#include <boost/asio.hpp>
|
2014-02-01 07:09:55 +04:00
|
|
|
|
2014-01-30 07:28:07 +04:00
|
|
|
namespace i2p
|
|
|
|
{
|
|
|
|
namespace util
|
|
|
|
{
|
2014-01-31 10:22:11 +04:00
|
|
|
namespace http
|
|
|
|
{
|
2016-02-19 18:04:52 +03:00
|
|
|
// in (lower case)
|
|
|
|
const char ETAG[] = "etag"; // ETag
|
|
|
|
const char LAST_MODIFIED[] = "last-modified"; // Last-Modified
|
|
|
|
const char TRANSFER_ENCODING[] = "transfer-encoding"; // Transfer-Encoding
|
|
|
|
const char CONTENT_ENCODING[] = "content-encoding"; // Content-Encoding
|
|
|
|
// out
|
2014-12-24 17:45:25 +03:00
|
|
|
const char IF_NONE_MATCH[] = "If-None-Match";
|
2016-02-19 18:04:52 +03:00
|
|
|
const char IF_MODIFIED_SINCE[] = "If-Modified-Since";
|
|
|
|
|
2015-02-20 20:21:33 +03:00
|
|
|
std::string GetHttpContent (std::istream& response);
|
2014-12-23 05:20:39 +03:00
|
|
|
void MergeChunkedResponse (std::istream& response, std::ostream& merged);
|
2015-02-07 20:34:25 +03:00
|
|
|
std::string urlDecode(const std::string& data);
|
2014-04-18 02:54:15 +04:00
|
|
|
|
2014-01-31 10:22:11 +04:00
|
|
|
struct url {
|
|
|
|
url(const std::string& url_s); // omitted copy, ==, accessors, ...
|
|
|
|
private:
|
|
|
|
void parse(const std::string& url_s);
|
|
|
|
public:
|
2014-04-07 00:18:55 +04:00
|
|
|
std::string protocol_, host_, path_, query_;
|
2014-04-18 00:22:54 +04:00
|
|
|
std::string portstr_;
|
|
|
|
unsigned int port_;
|
|
|
|
std::string user_;
|
|
|
|
std::string pass_;
|
2014-01-31 10:22:11 +04:00
|
|
|
};
|
|
|
|
}
|
2014-10-31 21:17:52 +03:00
|
|
|
|
|
|
|
namespace net
|
|
|
|
{
|
|
|
|
int GetMTU (const boost::asio::ip::address& localAddress);
|
|
|
|
}
|
2014-01-30 07:28:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|