CGI size
This commit is contained in:
@ -272,7 +272,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
|
||||
|
||||
if (req.getMethod() == "POST" || req.getMethod() == "PUT") {
|
||||
long len = req.isExistingField("Content-Length") ? strtol(req.getField("Content-Length").c_str(), nullptr, 10) : -1;
|
||||
socket->receive(pipes.stdin);
|
||||
socket->receive(pipes.stdin, len);
|
||||
}
|
||||
fclose(pipes.stdin);
|
||||
|
||||
|
@ -376,6 +376,17 @@ void Socket::receive(FILE *file) {
|
||||
} while (len > 0 && len == CHUNK);
|
||||
}
|
||||
|
||||
void Socket::receive(FILE *file, long size) {
|
||||
char buffer[CHUNK];
|
||||
long len = 0;
|
||||
long rec = 0;
|
||||
do {
|
||||
len = receive((void*) buffer, (CHUNK > (size - rec) && size >= 0)?(size - rec):CHUNK);
|
||||
fwrite(buffer, 1, CHUNK, file);
|
||||
rec += len;
|
||||
} while (len > 0 && size != len);
|
||||
}
|
||||
|
||||
string Socket::receiveLine() {
|
||||
string str = receive("\n");
|
||||
if (str.length() > 0 && str.at(str.length() - 1) == '\r') {
|
||||
|
@ -149,6 +149,7 @@ public:
|
||||
|
||||
static long select(list<Socket> read, list<Socket> write);
|
||||
|
||||
void receive(FILE *file, long size);
|
||||
};
|
||||
|
||||
Socket operator<<(Socket sock, const char *str);
|
||||
|
Reference in New Issue
Block a user