Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void client::http1_1(const char *argv[]) {
- int port = std::stoi(argv[2]);
- std::string server_ip = argv[1];
- std::ifstream inFile;
- client::net::socketstream ss;
- std::string s;
- inFile.open(argv[3]);
- if (!inFile) {
- std::cerr << "Unable to open file";
- exit(1);
- }
- if (ss.open(server_ip, port)) {
- std::vector<std::string> requests;
- while (std::getline(inFile, s))
- requests.push_back(s);
- // Start receiving thread
- std::thread receiving(&receive_thread, requests, std::ref(ss));
- for (int i = 0; i < requests.size(); i++) {
- std::vector<std::string> results;
- boost::split(results, requests[i], [](char c) { return c == ' '; });
- if (i != requests.size() - 1)
- request::GET(results[1], client::http_version_1_1, client::user_agent, server_ip, true,
- filesys::get_content_type(results[1]), ss);
- else
- request::GET(results[1], client::http_version_1_1, client::user_agent, server_ip, false,
- filesys::get_content_type(results[1]), ss);
- sem.notify();
- }
- receiving.join();
- } else {
- std::cerr << "Failed to connect to the server" << std::endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement