|
|
|
@ -45,7 +45,7 @@ namespace pEp {
|
|
|
|
|
|
|
|
|
|
HTTPSDevice::HTTPSDevice(string url, string user_agent, int version)
|
|
|
|
|
: _url(url), _user_agent(user_agent), _version(version),
|
|
|
|
|
_stream(nullptr)
|
|
|
|
|
_stream(nullptr), notifyRead(nullptr)
|
|
|
|
|
{
|
|
|
|
|
if (version != 11)
|
|
|
|
|
throw logic_error("only HTTP version 1.1 implemented");
|
|
|
|
@ -54,7 +54,8 @@ namespace pEp {
|
|
|
|
|
|
|
|
|
|
HTTPSDevice::HTTPSDevice(const HTTPSDevice& second)
|
|
|
|
|
: _url(second._url), _user_agent(second._user_agent),
|
|
|
|
|
_version(second._version), _stream(nullptr)
|
|
|
|
|
_version(second._version), _stream(nullptr),
|
|
|
|
|
notifyRead(second.notifyRead)
|
|
|
|
|
{
|
|
|
|
|
_parser.body_limit(1000000000);
|
|
|
|
|
}
|
|
|
|
@ -64,7 +65,7 @@ namespace pEp {
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HTTPSDevice::open(string url, notifyRead_t notifyRead)
|
|
|
|
|
void HTTPSDevice::open(string url, notifyRead_t *notifyRead)
|
|
|
|
|
{
|
|
|
|
|
if (url == "") {
|
|
|
|
|
if (_url != "")
|
|
|
|
@ -125,7 +126,7 @@ namespace pEp {
|
|
|
|
|
get(u.path, notifyRead);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HTTPSDevice::get(string path, notifyRead_t notifyRead)
|
|
|
|
|
void HTTPSDevice::get(string path, notifyRead_t *notifyRead)
|
|
|
|
|
{
|
|
|
|
|
if (path == "")
|
|
|
|
|
throw invalid_argument("path needed for GET");
|
|
|
|
@ -151,7 +152,7 @@ namespace pEp {
|
|
|
|
|
|
|
|
|
|
http::read_header(*_stream, b, _parser);
|
|
|
|
|
if (header()["Content-Length"] != "0" && notifyRead)
|
|
|
|
|
notifyRead();
|
|
|
|
|
(*notifyRead)();
|
|
|
|
|
|
|
|
|
|
http::read(*_stream, b, _parser);
|
|
|
|
|
|
|
|
|
|