APPLEMAIL-24
Volker Birk 4 years ago
parent d137fbbf3b
commit abbe5353da
  1. 11
      HTTPSStream.cc
  2. 2
      HTTPSStream.hh
  3. 1
      UpdateStream.hh
  4. 11
      test_https.cc

@ -97,8 +97,6 @@ namespace pEp {
throw;
}
_content_length = 0;
if (u.path != "")
get(u.path);
}
@ -110,7 +108,6 @@ namespace pEp {
if (!_stream)
open();
_content_length = 0;
_filename = "";
http::request<http::string_body> req{http::verb::get, path, _version};
@ -124,13 +121,7 @@ namespace pEp {
boost::beast::flat_buffer b;
http::read(*_stream, b, _res);
// BUG: Chunked transfer encoding not yet implemented, so
// Content-Length is mandatory
auto cl = header()["Content-Length"];
if (cl.size())
_content_length = stol(string(cl.data(), cl.size()));
cl = header()["Content-Disposition"];
auto cl = header()["Content-Disposition"];
static auto filename_pattern = " filename=\"(?<filename>[^\"]+)\"";
static boost::regex e(filename_pattern);
boost::match_results<string::const_iterator> what;

@ -40,7 +40,6 @@ namespace pEp {
string _host;
http::response<http::dynamic_body> _res;
size_t _content_length;
string _filename;
public:
@ -72,7 +71,6 @@ namespace pEp {
const http::fields& header() const { return _res; }
const auto& body() const { return _res.body(); }
size_t content_length() const { return _content_length; }
string filename() const { return _filename; }
streamsize read(char* s, streamsize n);

@ -42,7 +42,6 @@ namespace pEp {
void close();
string filename() { return _https->filename(); }
size_t content_length() { return _https->content_length(); }
};
typedef io::stream< UpdateDevice > UpdateStream;

@ -18,12 +18,15 @@ int main()
cout << f->name_string() << ": " << f->value() << "\n";
}
string body { boost::asio::buffers_begin(https.body().data()), boost::asio::buffers_end(https.body().data()) };
cout << body;
https.close();
https.read(nullptr, 0);
HTTPSStream httpss { HTTPSDevice { "https://pep.foundation" }, std::ios::binary };
httpss->get("/");
https.close();
std::stringstream str;
str << httpss.rdbuf();
cout << str.str();
return 0;
}

Loading…
Cancel
Save