<commit_before>/******************************************************************
*
* uHTTP for C++
*
* Copyright (C) <NAME> 2002-2013
*
* This is licensed under BSD-style license, see file COPYING.
*
******************************************************************/


#include <uhttp/net/Socket.h>
#include <uhttp/http/HTTPServerThread.h>

#include <sstream>

using namespace uHTTP;
using namespace uHTTP;

////////////////////////////////////////////////
//  Constructor
////////////////////////////////////////////////
  
HTTPServerThread::HTTPServerThread(HTTPServer *server, Socket *sock) {
  clientSock = sock;
  httpServer = server;
}

HTTPServerThread::~HTTPServerThread() {
}

////////////////////////////////////////////////
//  run  
////////////////////////////////////////////////

void HTTPServerThread::run() {
  HTTPSocket httpSock(clientSock);
  if (httpSock.open() == false) {
    delete clientSock;
    delete this;
    return;
  }
  HTTPRequest httpReq;
  httpReq.setSocket(&httpSock);
  while (httpReq.read() == true) {
    httpServer->performRequestListener(&httpReq);
    if (httpReq.isKeepAlive() == false)
      break;
  }
  httpSock.close();
  delete clientSock;
  delete this;
}<commit_msg>* Updated HTTPServerThread::run() to create the internal instances using 'new'.<commit_after>/******************************************************************
*
* uHTTP for C++
*
* Copyright (C) <NAME> 2002-2013
*
* This is licensed under BSD-style license, see file COPYING.
*
******************************************************************/


#include <uhttp/net/Socket.h>
#include <uhttp/http/HTTPServerThread.h>

#include <sstream>

using namespace uHTTP;
using namespace uHTTP;

////////////////////////////////////////////////
//  Constructor
////////////////////////////////////////////////
  
HTTPServerThread::HTTPServerThread(HTTPServer *server, Socket *sock) {
  clientSock = sock;
  httpServer = server;
}

HTTPServerThread::~HTTPServerThread() {
}

////////////////////////////////////////////////
//  run  
////////////////////////////////////////////////

void HTTPServerThread::run() {
  HTTPSocket *httpSock = new HTTPSocket(clientSock);
  if (!httpSock)
    return;

  if (httpSock->open() == false) {
    delete httpSock;
    delete clientSock;
    delete this;
    return;
  }

  HTTPRequest *httpReq = new HTTPRequest();
  if (!httpReq)
    return;

  httpReq->setSocket(httpSock);
  while (httpReq->read() == true) {
    httpServer->performRequestListener(httpReq);
    if (httpReq->isKeepAlive() == false)
      break;
  }
  httpSock->close();

  delete httpReq;
  delete httpSock;

  delete clientSock;
  delete this;
}
{'fraction_non_alphanumeric': 0.34257871064467765, 'fraction_numerical': 0.005997001499250375, 'mean_word_length': 2.327930174563591, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4721487', 'n_tokens_mistral': 745, 'n_tokens_neox': 711, 'n_words': 161}