| 144 | //------------------------------------------------------------------------------ |
| 145 | |
| 146 | int main(int argc, char** argv) |
| 147 | { |
| 148 | // Check command line arguments. |
| 149 | if(argc != 5 && argc != 6) |
| 150 | { |
| 151 | std::cerr << |
| 152 | "Usage: http-client-async-local <path> <host> <port> <target> [<HTTP version: 1.0 or 1.1(default)>]\n" << |
| 153 | "Example:\n" << |
| 154 | " http-client-async-local /tmp/http.sock localhost 80 /\n" << |
| 155 | " http-client-async-local /tmp/http.sock localhost 80 / 1.0\n"; |
| 156 | return EXIT_FAILURE; |
| 157 | } |
| 158 | auto const path = argv[1]; |
| 159 | auto const host = argv[2]; |
| 160 | auto const port = argv[3]; |
| 161 | auto const target = argv[4]; |
| 162 | int version = argc == 6 && !std::strcmp("1.0", argv[5]) ? 10 : 11; |
| 163 | |
| 164 | // The io_context is required for all I/O |
| 165 | net::io_context ioc; |
| 166 | |
| 167 | // Launch the asynchronous operation |
| 168 | std::make_shared<session>(ioc)->run(path, host, port, target, version); |
| 169 | |
| 170 | // Run the I/O service. The call will return when |
| 171 | // the get operation is complete. |
| 172 | ioc.run(); |
| 173 | |
| 174 | return EXIT_SUCCESS; |
| 175 | } |
| 176 | |
| 177 | #else |
| 178 | |