read.c 914 Bytes
#include <stdlib.h>
#include <unistd.h>

#include "http/request/parser.h"

#define MAX(x,y)    ((x) > (y) ? (x) : (y))
#define _BSIZE(x)   (MAX((x),RESPONSE_WRITER_MAX_BUF))
#define BSIZE       _BSIZE(this->nheader+message->nbody)


/**
 * @deprecated
 */
ssize_t
httpRequestParserRead(HttpRequestParser this, int fd)
{
	size_t  rsize;
	ssize_t temp;

	this->bend = (this->bsize == this->bend)?
		0 : this->bend;

	rsize      = (this->bstart <= this->bend)?
		this->bsize - this->bend :
		this->bstart - 1;

	if (0 >= (temp = read(fd, &(this->buffer[this->bend]), rsize))) {
		/**
		 * this means either we had an rsize of 0 what indicates that
		 * the buffer ran full without any processing took place or
		 * the connection was terminated in some way. In both cases
		 * we want to terminate the connection.
		 */
		return (0 == temp)? -2 : -1;
	}

	this->bend += temp;

	return temp;
}

// vim: set ts=4 sw=4: