Support chunked response content (but no Trailer headers).

This commit is contained in:
Chunting Gu
2019-01-31 18:10:12 +08:00
parent 01c7a6e328
commit 8d9855f751
11 changed files with 290 additions and 97 deletions
+25 -13
View File
@@ -3,19 +3,37 @@
#include "webcc/http_ssl_client.h"
#include "webcc/logger.h"
void Test() {
int main(int argc, char* argv[]) {
std::string host;
std::string url;
if (argc != 3) {
host = "www.boost.org";
url = "/LICENSE_1_0.txt";
} else {
host = argv[1];
url = argv[2];
}
std::cout << "Host: " << host << std::endl;
std::cout << "URL: " << url << std::endl;
std::cout << std::endl;
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
webcc::HttpRequest request;
request.set_method(webcc::kHttpGet);
request.set_url("/LICENSE_1_0.txt");
// Leave port to default value.
request.set_host("www.boost.org");
request.set_url(url);
request.set_host(host); // Leave port to default value.
request.Make();
webcc::HttpSslClient client;
if (client.Request(request)) {
// Verify the certificate of the peer or not.
// See HttpSslClient::Request() for more details.
bool ssl_verify = false;
if (client.Request(request, ssl_verify)) {
std::cout << client.response()->content() << std::endl;
} else {
std::cout << webcc::DescribeError(client.error());
@@ -24,12 +42,6 @@ void Test() {
}
std::cout << std::endl;
}
}
int main() {
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
Test();
return 0;
}