1 #include <msp/core/application.h>
2 #include <msp/core/getopt.h>
3 #include <msp/http/client.h>
4 #include <msp/http/request.h>
5 #include <msp/http/response.h>
6 #include <msp/io/print.h>
11 class HttpGet: public RegisteredApplication<HttpGet>
18 HttpGet(int, char **);
23 HttpGet::HttpGet(int argc, char **argv):
27 getopt.add_option('v', "verbose", verbose, GetOpt::NO_ARG);
30 const vector<string> &args = getopt.get_args();
32 throw usage_error("No URL");
43 IO::print("=== Sending request ===\n");
44 client.start_request(Http::Request::from_url(url));
45 IO::print(client.get_request()->str());
46 client.wait_response();
47 const Http::Response *response = client.get_response();
48 IO::print("=== Got response ===\n");
49 IO::print(response->str());
53 const Http::Response *response = client.get_url(url);
54 IO::print(response->get_content());