Beispiel #1
0
static int
readProxyResponse(int fd)
{
	FD	*f;
	Buf	*buf;

	f = table[fd];
	buf = readStream(fd, (unsigned char *) "readProxyResponse");
	send(f->writeFD, current(buf), inputLength(buf), 0);
	if (!logResponse(f, buf))
	{
		bufFree(buf);
	}
	removeFD(f->writeFD);
	removeFD(fd);

	return 0;
}
Beispiel #2
0
void Connection::onDataRead(std::size_t size)
{
    resetTimeoutTimer();

    for (int i = 0; i < size; i++)
    {
        char byte = buff_[i];

        try
        {
            current_request_->feedByte(byte);
        }
        catch (HTTPRequest::RequestReady &)
        {
            boost::system::error_code ec;
            current_request_->setIPAddress(client_socket_->remote_endpoint(ec).address().to_string());

            if (ec)
            {
                connectionClosing();
                return;
            }

            std::shared_ptr<HTTPResponse> response(new HTTPResponse);
            application_pointer_->onNewRequest(*current_request_, response);

            sendResponse(response.get());

            logResponse(current_request_, response);

            current_request_.reset(new HTTPRequest);
        }
        catch (HTTPRequest::HeaderFormatError &)
        {
            current_request_.reset(new HTTPRequest);
        }
    }

}