You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
835 B
C++

#include <iostream>
#include "webcc/http_client.h"
#include "webcc/logger.h"
// In order to test this client, create a file index.html whose content is
// simply "Hello, World!", then start a HTTP server with Python 3:
// $ python -m http.server
// The default port number should be 8000.
void Test() {
webcc::HttpRequest request(webcc::kHttpGet, "/index.html", "localhost",
"8000");
request.Make();
webcc::HttpClient client;
if (client.Request(request)) {
std::cout << client.response()->content() << std::endl;
} else {
std::cout << webcc::DescribeError(client.error());
if (client.timed_out()) {
std::cout << " (timed out)";
}
std::cout << std::endl;
}
}
int main() {
WEBCC_LOG_INIT("", webcc::LOG_CONSOLE);
Test();
Test();
Test();
return 0;
}