|
|
|
|
@ -30,6 +30,7 @@ WebServerClient::~WebServerClient () {
|
|
|
|
|
/// @param _ssl_cert
|
|
|
|
|
/// @return
|
|
|
|
|
int WebServerClient::Accept (TCP *socket, std::string _ssl_key, std::string _ssl_cert) {
|
|
|
|
|
debug ("");
|
|
|
|
|
if (ssl) delete ssl;
|
|
|
|
|
ssl = NULL;
|
|
|
|
|
if (tcp) delete tcp;
|
|
|
|
|
@ -51,6 +52,7 @@ int WebServerClient::Accept (TCP *socket, std::string _ssl_key, std::string _ssl
|
|
|
|
|
/// @param socket
|
|
|
|
|
/// @return
|
|
|
|
|
int WebServerClient::Accept (TCP *socket) {
|
|
|
|
|
debug ("");
|
|
|
|
|
if (ssl) delete ssl;
|
|
|
|
|
ssl = NULL;
|
|
|
|
|
if (tcp) delete tcp;
|
|
|
|
|
@ -74,6 +76,7 @@ WebRequestBuffer *WebServerClient::Loop () {
|
|
|
|
|
else {
|
|
|
|
|
len = tcp->ReadTimeout(buffer, WEB_READ_BUFFER_SIZE, 20);
|
|
|
|
|
}
|
|
|
|
|
if (len != 0) debug ("len: %d", len);
|
|
|
|
|
if (len < 0) return NULL;
|
|
|
|
|
if (len == 0) return &ReqBuffer;
|
|
|
|
|
ReqBuffer.AddBuffer (buffer, len);
|
|
|
|
|
@ -450,7 +453,7 @@ int WebServer::Loop() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tcpclient) {
|
|
|
|
|
|
|
|
|
|
debug ("new connection ssl_enabled:%d", ssl_enabled);
|
|
|
|
|
if (webclients.size() > conf_maxclients) {
|
|
|
|
|
printf ("max connections reached. closing connection.\n");
|
|
|
|
|
tcpclient->Close();
|
|
|
|
|
@ -481,8 +484,11 @@ int WebServer::Loop() {
|
|
|
|
|
|
|
|
|
|
reqbuffer = webclient->Loop();
|
|
|
|
|
if (reqbuffer == NULL) {
|
|
|
|
|
debug ("remove client");
|
|
|
|
|
// error on loop, remove and delete webclient.
|
|
|
|
|
debug ("count webclients:%d", webclients.size());
|
|
|
|
|
webclients.remove(webclient);
|
|
|
|
|
debug ("count webclients:%d", webclients.size());
|
|
|
|
|
delete webclient;
|
|
|
|
|
wci = webclients.begin();
|
|
|
|
|
if (wci == webclients.end()) break;
|
|
|
|
|
|