MCPcopy Create free account
hub / github.com/SpartanJ/eepp / main

Function main

src/examples/http_request/http_request.cpp:21–339  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21EE_MAIN_FUNC int main( int argc, char* argv[] ) {
22 args::ArgumentParser parser( "HTTP request program example" );
23 args::HelpFlag help( parser, "help", "Display this help menu", { 'h', "help" } );
24 args::Flag resume( parser, "continue", "Resume getting a partially-downloaded file",
25 { 'c', "continue" } );
26 args::Flag compressed( parser, "compressed", "Request compressed response", { "compressed" } );
27 args::ValueFlagList<std::string> postData( parser, "data", "HTTP POST data",
28 { 'd', "data", "data-raw" } );
29 args::ValueFlagList<std::string> postDataRaw( parser, "data-raw", "HTTP POST data RAW",
30 { "data-raw" } );
31 args::ValueFlagList<std::string> postUrlEncode(
32 parser, "data-urlencode",
33 "Post data, similar to the other -d, --data options with the exception that this performs "
34 "URL-encoding.",
35 { "data-urlencode" } );
36 args::ValueFlagList<std::string> multipartData(
37 parser, "multipart-data", "Specify multipart MIME data", { 'F', "form" } );
38 args::ValueFlagList<std::string> headers( parser, "header", "Pass custom header(s) to server",
39 { 'H', "header" } );
40 args::Flag includeHead( parser, "include", "Include protocol response headers in the output",
41 { 'i', "include" } );
42 args::Flag insecure( parser, "insecure", "Allow insecure server connections when using SSL",
43 { 'k', "insecure" } );
44 args::Flag location( parser, "location", "Follow redirects", { 'L', "location" } );
45 args::ValueFlag<unsigned int> maxRedirs(
46 parser, "max-redirs", "Maximum number of redirects allowed", { "max-redirs" } );
47 args::ValueFlag<std::string> output( parser, "file", "Write to file instead of stdout",
48 { 'o', "output" } );
49 args::ValueFlag<std::string> proxy( parser, "proxy", "[protocol://]host[:port] Use this proxy",
50 { 'x', "proxy" } );
51 args::Flag progress( parser, "progress", "Show current progress of a download",
52 { 'p', "progress" } );
53 args::Flag verbose( parser, "verbose", "Make the operation more talkative",
54 { 'v', "verbose" } );
55 args::ValueFlag<std::string> requestMethod( parser, "request", "Specify request command to use",
56 { 'X', "request" } );
57 args::Positional<std::string> url( parser, "URL", "The URL to request" );
58
59 try {
60 parser.ParseCLI( argc, argv );
61 } catch ( const args::Help& ) {
62 std::cout << parser;
63 return EXIT_SUCCESS;
64 } catch ( const args::ParseError& e ) {
65 std::cerr << e.what() << std::endl;
66 std::cerr << parser;
67 return EXIT_FAILURE;
68 } catch ( args::ValidationError& e ) {
69 std::cerr << e.what() << std::endl;
70 std::cerr << parser;
71 return EXIT_FAILURE;
72 }
73
74 {
75 // Create a new HTTP client
76 Http http;
77 Http::Request request;
78

Callers

nothing calls this directly

Calls 15

encodeFunction · 0.85
formatFunction · 0.85
printResponseHeadersFunction · 0.85
SecondsFunction · 0.85
setValidateHostnameMethod · 0.80
getPortMethod · 0.80
setUriMethod · 0.80
getPathEtcMethod · 0.80
find_first_ofMethod · 0.80
substrMethod · 0.80
setFieldMethod · 0.80

Tested by

no test coverage detected