read.c
1.38 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#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)
{
/**
* @obsolete
*/
return -1;
// size_t remaining, chunks;
// char buffer[1024];
//
// ssize_t size = read(fd, buffer, 1024);
//
// if (0 < size) {
// remaining = this->buffer_used % HTTP_REQUEST_PARSER_READ_CHUNK;
// remaining = HTTP_REQUEST_PARSER_READ_CHUNK - remaining;
// chunks = this->buffer_used / HTTP_REQUEST_PARSER_READ_CHUNK;
//
// /**
// * because a division always rounds down
// * chunks holds exactly the currently allocated chunks if
// * remaining equals 0 but there is no space left.
// * Else chunks holds the actually allocated amount of chunks
// * minus 1.
// * For this reason chunks always has to be increased by 1.
// */
// chunks++;
//
// if (size >= remaining) {
// this->buffer =
// realloc(this->buffer, chunks * HTTP_REQUEST_PARSER_READ_CHUNK);
// }
//
// memcpy(this->buffer + this->buffer_used, buffer, size);
// this->buffer_used += size;
// this->buffer[this->buffer_used] = 0;
//
// size = httpRequestParserParse(this);
// }
// else {
// size = (0 == size)? -2 : size;
// }
//
// return size;
}
// vim: set ts=4 sw=4: