read.c
914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#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: