#include "client.h" #include #include Client::Client() { socket = 0; close_connection = false; PrepareToNewRequest(); read_static_buffer_size = 1500 * 30; // 1500 * 30 // this will be testing (size of one packet * how many packets) read_static_buffer = new char[read_static_buffer_size]; // add to config std::cout << "alokuje buforek: " << (void*)read_static_buffer << std::endl; // check whether there is no too much copying when we add Client to a list } Client::Client(const Client & c) { operator=(c); } Client::~Client() { std::cout << "usuwam buforek: " << (void*)read_static_buffer << std::endl; delete [] read_static_buffer; } Client & Client::operator=(const Client & c) { socket = c.socket; parsing_headers = c.parsing_headers; parsing_first_header = c.parsing_first_header; http_method_str = c.http_method_str; http_method = c.http_method; http_version = c.http_version; url = c.url; answer_generated = c.answer_generated; output_buffer = c.output_buffer; output_buffer_sent = c.output_buffer_sent; close_connection = c.close_connection; output_buffer_two = c.output_buffer_two; //is_sending_file = c.is_sending_file; // external_resource_fd = c.external_resource_fd; // waiting_for_last_read = c.waiting_for_last_read; // send_file = c.send_file; // file_how_many_read = c.file_how_many_read; //file_has_been_read = c.file_has_been_read; // file_len = c.file_len; //file_how_many_send = c.file_how_many_send; output_buffer_two_sent = c.output_buffer_two_sent; external_resource = c.external_resource; reading_to_buffer = c.reading_to_buffer; sending_from_buffer = c.sending_from_buffer; reading_to_buffer_two = c.reading_to_buffer_two; sending_from_buffer_two = c.sending_from_buffer_two; answering_to_client = c.answering_to_client; // reading_external_resource = c.reading_external_resource; read_static_buffer_size = c.read_static_buffer_size; read_static_buffer = new char[read_static_buffer_size]; std::cout << "alokuje buforek: " << (void*)read_static_buffer << std::endl; memcpy(read_static_buffer, c.read_static_buffer, read_static_buffer_size); out_headers = c.out_headers; status = c.status; return *this; } void Client::PrepareToNewRequest() { parsing_headers = true; parsing_first_header = true; http_method = http_method_unsupported; http_version = http_version_unsupported; answer_generated = false; output_buffer_sent = 0; //is_sending_file = false; //external_resource_fd = -1; //waiting_for_last_read = false; //file_how_many_read = 0; //file_has_been_read = false; output_buffer_two_sent = 0; //file_len = 0; //file_how_many_send = 0; reading_to_buffer_two = false; sending_from_buffer_two = false; reading_to_buffer = 0; sending_from_buffer = 0; answering_to_client = false; //reading_external_resource = false; http_method_str.clear(); output_buffer.clear(); output_buffer_two.clear(); url.clear(); send_file.clear(); external_resource.Clear(); memset(&iocb, 0, sizeof(iocb)); out_headers.Clear(); status = 404; // don't set flag close_connection to false here }