Merge branch 'hugo2'

+ changed the appropriate getters for client
+ moved the functions to parse the http message
  (first line, headers, and body)
  outside client, in parsing_http_message.cpp
+ resolved some of the throw problems
This commit is contained in:
hugogogo
2022-08-09 15:54:40 +02:00
24 changed files with 205391 additions and 214 deletions

View File

@@ -17,8 +17,8 @@
# include <iostream> // cout, cin
# include <cstring> // memset
# include <sys/socket.h> // socket, accept, listen, send, recv, bind, connect, setsockopt, getsockname
# include <arpa/inet.h> // htonl, htons, ntohl, ntohs, inet_addr
# include <netinet/in.h> // sockaddr_in
# include <arpa/inet.h> // htonl, htons, ntohl, ntohs, inet_addr, inet_ntoa
# include <netinet/in.h> // sockaddr_in, struct in_addr
// # include <netinet/ip.h> // usefull for what ? -> 'man (7) ip' says it's a superset of 'netinet/in.h'
# include <algorithm> // find
# include <string> // string
@@ -34,7 +34,7 @@
extern bool g_run;
extern int g_last_signal;
void signal_handler(int signum);
void signal_handler(int signum);
// these might only be TMP
# define FAILURE -1
@@ -70,21 +70,23 @@ class Webserv
// accept.cpp
void _accept_connection(listen_socket &lsocket);
std::map<std::string, std::string>
_extract_infos(struct sockaddr_in addr);
// request.cpp
void _request(Client *client);
int _read_request(Client *client);
// response.cpp
void _response(Client *client);
int _send_response(Client *client);
void _append_base_headers(Client *client);
void _construct_response(Client *client);
void _process_method(Client *client);
void _insert_status_line(Client *client);
void _error_html_response(Client *client);
void _append_body(Client *client, const std::string &body, const std::string &file_extension = "");
ServerConfig *_determine_process_server(Client *client); // cant be const cause of error_pages.operator[]
void _response(Client *client);
int _send_response(Client *client);
void _append_base_headers(Client *client);
void _construct_response(Client *client);
void _process_method(Client *client);
void _insert_status_line(Client *client);
void _error_html_response(Client *client);
void _append_body(Client *client, const std::string &body, const std::string &file_extension = "");
ServerConfig *_determine_process_server(Client *client); // cant be const cause of error_pages.operator[]
const LocationConfig *_determine_location(const ServerConfig &server, const std::string &path) const;
std::string _determine_file_extension(const std::string &path) const;
std::string _determine_file_extension(const std::string &path) const;
// method_get.cpp
void _get(Client *client);
void _get_file(Client *client, const std::string &path);
@@ -96,12 +98,15 @@ class Webserv
void _delete(Client *client);
void _delete_file(Client *client, const std::string &path);
// cgi_script.cpp
bool _is_cgi(Client *client);
void _exec_cgi(Client *client);
void _construct_client(Client *client);
char** _set_env(Client *client);
char* _dup_env(std::string var, std::string val);
void _exec_script(Client *client, char **env);
bool _is_cgi(Client *client);
std::string _exec_cgi(Client *client);
char** _set_env(Client *client);
char* _dup_env(std::string var, std::string val);
char* _dup_env(std::string var, int i);
std::string _exec_script(Client *client, char **env);
void _check_script_output(Client *client, std::string output);
void _check_script_status(Client *client, std::string output);
void _check_script_fields(Client *client, std::string output);
// epoll_update.cpp
int _epoll_update(int fd, uint32_t events, int op);
int _epoll_update(int fd, uint32_t events, int op, void *ptr);
@@ -116,6 +121,8 @@ class Webserv
void _listen(int socket_fd, unsigned int max_connections);
void _init_http_status_map();
void _init_mime_types_map();
};
#endif

View File

@@ -3,9 +3,10 @@
void Webserv::_accept_connection(listen_socket &lsocket)
{
struct sockaddr_in addr;
socklen_t addr_len;
int accepted_fd;
struct sockaddr_in addr;
socklen_t addr_len;
int accepted_fd;
std::map<std::string, std::string> infos;
std::cerr << "accept()\n";
addr_len = sizeof addr;
@@ -19,9 +20,22 @@ void Webserv::_accept_connection(listen_socket &lsocket)
}
::fcntl(accepted_fd, F_SETFL, O_NONBLOCK);
_clients.push_back(Client());
_clients.back().fd = accepted_fd;
_clients.back().lsocket = &lsocket;
infos = _extract_infos(addr);
Client client(accepted_fd, &lsocket, infos["port"], infos["ip"]);
_clients.push_back(client);
_epoll_update(accepted_fd, EPOLLIN, EPOLL_CTL_ADD);
}
std::map<std::string, std::string>
Webserv::_extract_infos(struct sockaddr_in addr)
{
struct in_addr ip_conversion;
std::map<std::string, std::string> infos;
infos["port"] = ::itos( addr.sin_port );
ip_conversion.s_addr = addr.sin_addr.s_addr;
infos["ip"] = inet_ntoa( ip_conversion );
return infos;
}

View File

@@ -3,18 +3,27 @@
bool Webserv::_is_cgi(Client *client)
{
if (client->get_path().find("/cgi-bin/") != std::string::npos)
// TODO see how it works with config
if (client->fill_script_path("/cgi-bin/php-cgi"))
return true;
if (client->fill_script_path("/cgi-bin/cgi_cpp.cgi"))
return true;
return false;
}
void Webserv::_exec_cgi(Client *client)
std::string Webserv::_exec_cgi(Client *client)
{
char** env;
char** env;
std::string script_output;
env = _set_env(client);
_exec_script(client, env);
// _construct_response(client);
script_output = _exec_script(client, env);
for (int i = 0; env[i]; i++)
delete[] env[i];
delete[] env;
return script_output;
}
char* Webserv::_dup_env(std::string var, std::string val = "")
@@ -25,56 +34,145 @@ char* Webserv::_dup_env(std::string var, std::string val = "")
return ( strdup(str.c_str()) );
}
char* Webserv::_dup_env(std::string var, int i)
{
std::string str;
std::string val;
val = ::itos(i);
str = var + "=" + val;
// TODO change strdup for something with new
return ( strdup(str.c_str()) );
}
char** Webserv::_set_env(Client *client)
{
char** env = new char*[19];
env[0] = _dup_env("AUTH_TYPE");
env[1] = _dup_env("CONTENT_LENGTH", "665");
env[2] = _dup_env("CONTENT_TYPE");
env[3] = _dup_env("GATEWAY_INTERFACE");
env[4] = _dup_env("PATH_INFO");
env[5] = _dup_env("PATH_TRANSLATED");
env[6] = _dup_env("QUERY_STRING");
env[7] = _dup_env("REMOTE_ADDR");
env[8] = _dup_env("REMOTE_HOST", client->get_headers("Host")); // just test
env[9] = _dup_env("REMOTE_IDENT");
env[10] = _dup_env("REMOTE_USER");
env[11] = _dup_env("REQUEST_METHOD", ::http_methods_to_str(client->get_method()));
env[12] = _dup_env("SCRIPT_NAME");
env[13] = _dup_env("SERVER_NAME");
env[14] = _dup_env("SERVER_PORT");
env[15] = _dup_env("SERVER_PROTOCOL", client->get_version());
env[16] = _dup_env("SERVER_SOFTWARE");
env[17] = _dup_env("REDIRECT_STATUS");
env[0] = _dup_env("AUTH_TYPE"); // authentification not supported
env[1] = _dup_env("CONTENT_LENGTH" , client->get_rq_body().size());
env[2] = _dup_env("CONTENT_TYPE" , client->get_rq_headers("Content-Type"));
env[3] = _dup_env("GATEWAY_INTERFACE" , "CGI/1.1"); // https://www.rfc-editor.org/rfc/rfc3875
env[4] = _dup_env("PATH_INFO" , client->get_rq_script_info());
env[5] = _dup_env("PATH_TRANSLATED"); // not supported
env[6] = _dup_env("QUERY_STRING" , client->get_rq_query());
env[7] = _dup_env("REMOTE_ADDR" , client->get_cl_ip());
env[8] = _dup_env("REMOTE_HOST" , client->get_rq_headers("Host")); // just test
env[9] = _dup_env("REMOTE_IDENT"); // authentification not supported
env[10] = _dup_env("REMOTE_USER"); // authentification not supported
env[11] = _dup_env("REQUEST_METHOD" , client->get_rq_method_str());
env[12] = _dup_env("SCRIPT_NAME" , client->get_rq_script_path());
env[13] = _dup_env("SERVER_NAME" , client->get_rq_hostname());
env[14] = _dup_env("SERVER_PORT" , client->get_rq_port());
env[15] = _dup_env("SERVER_PROTOCOL" , client->get_rq_version());
env[16] = _dup_env("SERVER_SOFTWARE" , "webser/1.0");
env[17] = _dup_env("REDIRECT_STATUS" , "200");
env[18] = NULL;
return env;
}
void Webserv::_exec_script(Client *client, char **env)
std::string Webserv::_exec_script(Client *client, char **env)
{
int save_stdout;
char * const * nll = NULL;
#define RD 0
#define WR 1
#define CGI_BUF_SIZE 10
#define FD_WR_TO_CHLD fd_in[WR]
#define FD_WR_TO_PRNT fd_out[WR]
#define FD_RD_FR_CHLD fd_out[RD]
#define FD_RD_FR_PRNT fd_in[RD]
// save STDOUT
save_stdout = dup(STDOUT_FILENO);
// inside child process
if (fork() == 0)
{
dup2(client->fd, STDOUT_FILENO);
// execve("./srcs/cgi-bin/cgi_cpp.cgi", nll, client->env);
execve("./srcs/cgi-bin/php-cgi", nll, env);
pid_t pid;
char buf[CGI_BUF_SIZE]; // WIP define buffer
char * const * nll = NULL;
std::string script_output;
std::string body = client->get_rq_body();
int fd_in[2];
int fd_out[2];
pipe(fd_in);
pipe(fd_out);
pid = fork();
if (pid == -1)
std::cerr << "fork crashed" << std::endl;
else if (pid == 0)
{
close(FD_WR_TO_CHLD);
close(FD_RD_FR_CHLD);
dup2(FD_RD_FR_PRNT, STDIN_FILENO);
dup2(FD_WR_TO_PRNT, STDOUT_FILENO);
// DEBUG
std::cerr << "execve:\n";
execve(client->get_rq_script_path().c_str(), nll, env);
// for tests execve crash :
//execve("wrong", nll, env);
std::cerr << "execve crashed.\n";
}
// inside parent process
else
{
close(FD_RD_FR_PRNT);
close(FD_WR_TO_PRNT);
write(FD_WR_TO_CHLD, body.c_str(), body.size());
close(FD_WR_TO_CHLD);
waitpid(-1, NULL, 0);
// restore stdout
dup2(save_stdout, STDOUT_FILENO);
memset(buf, '\0', CGI_BUF_SIZE);
while (read(FD_RD_FR_CHLD, buf, CGI_BUF_SIZE - 1) > 0)
{
script_output += buf;
memset(buf, '\0', CGI_BUF_SIZE);
}
close(FD_RD_FR_CHLD);
}
if (script_output.empty())
script_output = "Status: 500\r\n\r\n";
return script_output;
}
void Webserv::_construct_client(Client *client)
void Webserv::_check_script_output(Client *client, std::string output)
{
(void)client;
// TODO: it doesn't work with execve error, i don't know why yet ?
_check_script_status(client, output);
_check_script_fields(client, output);
}
void Webserv::_check_script_status(Client *client, std::string output)
{
size_t pos;
int status_pos;
pos = output.find("Status:");
if (pos != std::string::npos)
{
status_pos = pos + std::string("Status:").size();
client->status = atoi(output.c_str() + status_pos);
::del_line_in_str(&output, pos, CRLF);
}
client->status = 200;
}
void Webserv::_check_script_fields(Client *client, std::string output)
{
std::map<std::string, std::string> srv_fld; // server_field
std::map<std::string, std::string> scr_fld; // script_field
std::map<std::string, std::string>::iterator it_srv;
std::map<std::string, std::string>::iterator it_scr;
size_t pos;
srv_fld = parse_http_headers(client->response);
scr_fld = parse_http_headers(output);
// wip: compare both map to supress duplicates
for (it_srv = srv_fld.begin(); it_srv != srv_fld.end(); it_srv++)
{
for (it_scr = scr_fld.begin(); it_scr != scr_fld.end(); it_scr++)
{
if (it_srv->first == it_scr->first)
{
pos = client->response.find(it_srv->first);
::del_line_in_str(&client->response, pos, CRLF);
}
}
}
}

View File

@@ -25,10 +25,10 @@ void Webserv::_close_all_clients()
while (!_clients.empty())
{
// _epoll_update(_clients.back().fd, 0, EPOLL_CTL_DEL); // normalement superflu, DEBUG
if (::close(_clients.back().fd) == -1)
if (::close(_clients.back().get_cl_fd()) == -1)
std::perror("err close()");
else
std::cerr << "close fd " << _clients.back().fd << "\n";
std::cerr << "close fd " << _clients.back().get_cl_fd() << "\n";
_clients.pop_back();
}
}

View File

@@ -237,3 +237,4 @@ void Webserv::_init_mime_types_map()
_mime_types.insert(mime_pair("wmv", "video/x-ms-wmv"));
_mime_types.insert(mime_pair("avi", "video/x-msvideo"));
}

View File

@@ -7,7 +7,7 @@ void Webserv::_delete(Client *client)
WIP
https://www.rfc-editor.org/rfc/rfc9110.html#name-delete
*/
std::string path = client->get_path();
std::string path = client->get_rq_abs_path();
path.insert(0, client->assigned_location->root);
/* CGI Here ? */

View File

@@ -13,7 +13,7 @@ Where does cgi fit in in all this ???
*/
std::string path = client->get_path();
std::string path = client->get_rq_abs_path();
// this might not be the best thing, a voir
path.insert(0, client->assigned_location->root);
@@ -57,9 +57,15 @@ Where does cgi fit in in all this ???
// TMP HUGO
//
std::string script_output;
if (_is_cgi(client))
{
_exec_cgi(client);
script_output = _exec_cgi(client);
// DEBUG
std::cout << "\n____script_output____\n" << script_output << "\n_______________\n";
// wip check output of script
_check_script_output(client, script_output);
client->response += script_output;
return;
}
//

View File

@@ -8,7 +8,7 @@ void Webserv::_post(Client *client)
WIP
https://www.rfc-editor.org/rfc/rfc9110.html#name-post
*/
std::string path = client->get_path();
std::string path = client->get_rq_abs_path();
path.insert(0, client->assigned_location->root);
/* CGI Here ? */
@@ -46,7 +46,7 @@ void Webserv::_post_file(Client *client, const std::string &path)
// Maybe usefull in _read_request() for rejecting too big content.
// Need to _determine_process_server() as soon as possible,
// like in _read_request() for stopping read if body is too big ?
ofd << client->get_body();
ofd << client->get_rq_body();
if (!ofd)
{
std::cerr << path << ": ofd.write fail" << '\n';

View File

@@ -0,0 +1,90 @@
#include "parsing_message_http.hpp"
size_t
parse_http_first_line(std::string message, std::vector<std::string> &line)
{
std::vector<std::string> sline;
std::string sub;
std::string tmp;
size_t pos;
size_t ret;
// TODO: check for err in substr
pos = message.find(CRLF);
sub = message.substr(0, pos);
sline = ::split(sub, ' ');
ret = sline.size();
if (ret != 3)
return ret;
for (int i = 0; i < 3; i++)
{
tmp = ::trim(sline[i], ' ');
tmp = ::trim(tmp, '\r');
line.push_back(tmp);
}
return ret;
}
std::map<std::string, std::string>
parse_http_headers(std::string message)
{
std::map<std::string, std::string> headers;
std::vector<std::string> list;
std::vector<std::string>::iterator it;
std::string sub;
std::string key;
std::string val;
size_t pos;
pos = (message).find(CRLF CRLF);
sub = (message).substr(0, pos);
list = ::split(sub, '\n');
if ( maybe_http_first_line( *list.begin() ) )
list.erase(list.begin());
for (it = list.begin(); it != list.end(); it++)
{
// TODO: if pattern is not "NAME: value" return error
pos = (*it).find(':');
key = (*it).substr( 0, pos );
key = ::trim(key, ' ');
key = ::trim(key, '\r');
key = ::str_tolower(key);
val = (*it).substr( pos + 1 );
val = ::trim(val, ' ');
val = ::trim(val, '\r');
headers.insert( std::pair<std::string, std::string>(key, val) );
}
return headers;
}
std::string
parse_http_body(std::string message)
{
std::string body;
size_t pos;
pos = message.find(CRLF CRLF);
pos += std::string(CRLF CRLF).size();
// TODO: copying just like that might fail in case of binary or images
body = message.substr(pos);
return body;
}
bool maybe_http_first_line(std::string str)
{
// method SP target SP version https://www.rfc-editor.org/rfc/rfc7230.html#section-3.1.1
// version SP status SP reason https://www.rfc-editor.org/rfc/rfc7230.html#section-3.1.2
std::vector<std::string> sline;
sline = ::split(str, ' ');
if (sline.size() != 3)
return false;
if (sline[0].find(':') != std::string::npos)
return false;
return true;
}

View File

@@ -0,0 +1,36 @@
#ifndef PARSING_MESSAGE_HTTP_HPP
# define PARSING_MESSAGE_HTTP_HPP
# include <iostream>
# include <string>
# include <vector>
# include <map>
# include "utils.hpp"
size_t
parse_http_first_line(std::string message, std::vector<std::string> &line);
std::map<std::string, std::string>
parse_http_headers(std::string message);
std::string
parse_http_body(std::string message);
bool
maybe_http_first_line(std::string);
// http message structure :
//
// start-line
// request-line
// method SP target SP version
// response-line
// version SP status SP reason
// header-fields
// name ":" SP value
// CRLF
// body
#endif

View File

@@ -0,0 +1,2 @@
#include "parsing_request.hpp"

View File

@@ -20,11 +20,11 @@ void Webserv::_request(Client *client)
if (ret == READ_CLOSE)
{
_close_client(client->fd);
_close_client(client->get_cl_fd());
}
else if (ret == READ_COMPLETE)
{
_epoll_update(client->fd, EPOLLOUT, EPOLL_CTL_MOD);
_epoll_update(client->get_cl_fd(), EPOLLOUT, EPOLL_CTL_MOD);
}
}
@@ -34,13 +34,13 @@ int Webserv::_read_request(Client *client) // Messy, Need refactoring
ssize_t ret;
std::cerr << "call recv()" << "\n" ;
ret = ::recv(client->fd, buf, BUFSIZE, 0);
std::cerr << "recv() on fd(" << client->fd << ") returned = " << ret << "\n" ;
ret = ::recv(client->get_cl_fd(), buf, BUFSIZE, 0);
std::cerr << "recv() on fd(" << client->get_cl_fd() << ") returned = " << ret << "\n" ;
if (ret == -1)
{
std::perror("err recv()");
std::cerr << "client ptr =" << client << "\n"; // DEBUG
std::cerr << "client.fd =" << client->fd << "\n"; // DEBUG
std::cerr << "client.fd =" << client->get_cl_fd() << "\n"; // DEBUG
return READ_CLOSE;
}
if (ret == 0)
@@ -60,14 +60,14 @@ int Webserv::_read_request(Client *client) // Messy, Need refactoring
if (client->status) // WIP, need to change client->parse_request() for status update
return READ_COMPLETE;
client->assigned_server = _determine_process_server(client);
client->assigned_location = _determine_location(*client->assigned_server, client->get_path());
if (client->get_version().compare(0, sizeof("HTTP/1") - 1, "HTTP/1") != 0)
client->assigned_location = _determine_location(*client->assigned_server, client->get_rq_abs_path());
if (client->get_rq_version().compare(0, sizeof("HTTP/1") - 1, "HTTP/1") != 0)
{ // TODO : move in Client parsing ?
client->status = 505;
return READ_COMPLETE;
}
if (!client->get_headers("Content-Length").empty()
&& ::atoi(client->get_headers("Content-Length").c_str()) > (int)client->assigned_server->client_body_limit)
if (!client->get_rq_headers("Content-Length").empty()
&& ::atoi(client->get_rq_headers("Content-Length").c_str()) > (int)client->assigned_server->client_body_limit)
{
client->status = 413;
return READ_COMPLETE;
@@ -87,7 +87,7 @@ int Webserv::_read_request(Client *client) // Messy, Need refactoring
client->status = 413;
return READ_COMPLETE;
}
if ((int)client->read_body_size >= ::atoi(client->get_headers("Content-Length").c_str()))
if ((int)client->read_body_size >= ::atoi(client->get_rq_headers("Content-Length").c_str()))
{
client->parse_request(); // reparse for the body
return READ_COMPLETE;
@@ -95,7 +95,7 @@ int Webserv::_read_request(Client *client) // Messy, Need refactoring
}
if (client->header_complete && client->get_headers("Content-Type").empty() && client->get_headers("Content-Length").empty() )
if (client->header_complete && client->get_rq_headers("Content-Type").empty() && client->get_rq_headers("Content-Length").empty() )
{
return READ_COMPLETE;
}

View File

@@ -17,15 +17,15 @@ void Webserv::_response(Client *client)
if (ret == SEND_CLOSE)
{
_close_client(client->fd);
_close_client(client->get_cl_fd());
}
else if (ret == SEND_COMPLETE)
{
if (client->get_headers("Connection") == "close")
_close_client(client->fd);
if (client->get_rq_headers("Connection") == "close")
_close_client(client->get_cl_fd());
else
{
_epoll_update(client->fd, EPOLLIN, EPOLL_CTL_MOD);
_epoll_update(client->get_cl_fd(), EPOLLIN, EPOLL_CTL_MOD);
client->clear();
}
}
@@ -45,11 +45,11 @@ int Webserv::_send_response(Client *client)
_error_html_response(client);
std::cerr << "client->response.size() = " << client->response.size() << "\n"; // DEBUG
ret = ::send(client->fd, client->response.c_str(), client->response.size(), 0);
ret = ::send(client->get_cl_fd(), client->response.c_str(), client->response.size(), 0);
if (ret == -1)
{
std::perror("err send()");
std::cerr << "client.fd =" << client->fd << "\n"; // DEBUG
std::cerr << "client.fd =" << client->get_cl_fd() << "\n"; // DEBUG
return SEND_CLOSE;
}
std::cerr << "ret send() = " << ret << "\n"; // DEBUG
@@ -61,7 +61,7 @@ void Webserv::_append_base_headers(Client *client)
{
client->response.append("Server: Webserv/0.1" CRLF);
if (client->get_headers("Connection") == "close")
if (client->get_rq_headers("Connection") == "close")
client->response.append("Connection: close" CRLF);
else
client->response.append("Connection: keep-alive" CRLF);
@@ -70,7 +70,7 @@ void Webserv::_append_base_headers(Client *client)
void Webserv::_construct_response(Client *client)
{
// TODO : Move this in read(), stop read if content too large
if (client->get_body().size() > client->assigned_server->client_body_limit)
if (client->get_rq_body().size() > client->assigned_server->client_body_limit)
{
client->status = 413;
return;
@@ -83,7 +83,7 @@ void Webserv::_construct_response(Client *client)
client->response.append(client->assigned_location->redirect_uri);
client->response.append(CRLF);
} */
if (client->get_path().find("redirect_test") != std::string::npos) // Test block
if (client->get_rq_abs_path().find("redirect_test") != std::string::npos) // Test block
{ // Weird behavior. The web browser seems to wait for a complete response until timeout.
// (for codes 301, 302, 303, 307, and 308)
client->status = 307;
@@ -100,13 +100,13 @@ void Webserv::_process_method(Client *client)
{
std::cerr << "assigned_location->path = " << client->assigned_location->path << "\n"; // debug
std::cerr << "allow_methods = " << client->assigned_location->allow_methods << "\n"; // debug
if (client->get_method() == UNKNOWN)
if (client->get_rq_method() == UNKNOWN)
{
client->status = 501;
}
else if (client->assigned_location->allow_methods & client->get_method())
else if (client->assigned_location->allow_methods & client->get_rq_method())
{
switch (client->get_method())
switch (client->get_rq_method())
{
case (GET):
_get(client); break;
@@ -181,14 +181,14 @@ ServerConfig *Webserv::_determine_process_server(Client *client)
TODO : test it
*/
std::string &server_name = client->get_headers("Host");
std::string const &server_name = client->get_rq_headers("Host");
std::vector<ServerConfig>::iterator it = _servers.begin();
std::vector<ServerConfig>::iterator default_server = _servers.end();
while (it != _servers.end())
{
if (it->host == client->lsocket->host
&& it->port == client->lsocket->port)
if (it->host == client->get_cl_lsocket()->host
&& it->port == client->get_cl_lsocket()->port)
{
if ( std::find(it->server_name.begin(), it->server_name.end(), server_name) != it->server_name.end() )
break;