<commit_before><?php
namespace Niysu;

/**
 *
 * @copyright 	2012 <NAME> <<EMAIL>>
 * @license 	MIT http://opensource.org/licenses/MIT
 * @link 		http://github.com/Tomaka17/niysu
 */
class IPCServer {
	public function __construct(Server $server, $address) {
		$this->niysuServer = $server;
		$this->bindAddress = $address;
	}

	public function run() {
		if (ini_get('max_execution_time') != 0)
			throw new \LogicException('php must be executed from cli in order to start a server');

		if (($this->socket = stream_socket_server(self::getTransport(), $errNo, $errString)) === false)
			throw new \RuntimeException('Could not create listening socket: '.$errString);

		do {
			$readableSockets = [ $this->socket ];
			$write = null;
			$except = null;
			stream_select($readableSockets, $write, $except, 5);

			foreach ($readableSockets as $socket) {
				if ($socket === $this->socket) {
					$newSocket = stream_socket_accept($this->socket);

					try {
						$request = new HTTPRequestFromStream($newSocket);
						$response = new HTTPResponseToStream($newSocket);
						$this->niysuServer->handle($request, $response);
						stream_socket_shutdown($newSocket, STREAM_SHUT_RDWR);

					} catch(\Exception $e) {
						fwrite($newSocket, 'HTTP/1.1 500 Internal Server Error'."\r\n\r\n");
						fflush($newSocket);
						stream_socket_shutdown($newSocket, STREAM_SHUT_RDWR);
					}
				}
			}
		} while(true);

		stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
	}<commit_msg>Added server header to response<commit_after><?php
namespace Niysu;

/**
 *
 * @copyright 	2012 <NAME> <<EMAIL>>
 * @license 	MIT http://opensource.org/licenses/MIT
 * @link 		http://github.com/Tomaka17/niysu
 */
class IPCServer {
	public function __construct(Server $server, $address) {
		$this->niysuServer = $server;
		$this->bindAddress = $address;
	}

	public function run() {
		if (ini_get('max_execution_time') != 0)
			throw new \LogicException('PHP must have no max_execution_time in order to start a server');

		if (($this->socket = stream_socket_server(self::getTransport(), $errNo, $errString)) === false)
			throw new \RuntimeException('Could not create listening socket: '.$errString);

		do {
			$readableSockets = [ $this->socket ];
			$write = null;
			$except = null;
			stream_select($readableSockets, $write, $except, 5);

			foreach ($readableSockets as $socket) {
				if ($socket === $this->socket) {
					$newSocket = stream_socket_accept($this->socket);

					try {
						$request = new HTTPRequestFromStream($newSocket);
						$response = new HTTPResponseToStream($newSocket);
						$response->setHeader('Server', 'Niysu IPC server');
						$response->setHeader('Connection', 'close');
						$this->niysuServer->handle($request, $response);
						stream_socket_shutdown($newSocket, STREAM_SHUT_RDWR);

					} catch(\Exception $e) {
						fwrite($newSocket, 'HTTP/1.1 500 Internal Server Error'."\r\n");
						fwrite($newSocket, 'Server: Niysu IPC server'."\r\n\r\n");
						fflush($newSocket);
						stream_socket_shutdown($newSocket, STREAM_SHUT_RDWR);
					}
				}
			}
		} while(true);

		stream_socket_shutdown($this->socket, STREAM_SHUT_RDWR);
	}
{'fraction_non_alphanumeric': 0.15348101265822786, 'fraction_numerical': 0.008227848101265823, 'mean_word_length': 4.0015822784810124, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, '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': '3914336', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1031, 'n_words': 218}