add POST support and fix user specified scheme via commonrequest

This commit is contained in:
zhangzifa
2019-01-31 15:48:30 +08:00
committed by Jackson Tian
parent b429dcc915
commit 138dbdc61e
23 changed files with 215 additions and 49 deletions

View File

@@ -130,9 +130,10 @@ void ServerThread::Run() {
Terminate(true);
} else if (!strcmp("POST", method)) {
if (fopen(path, "r") > 0) {
sprintf(buffer, "%s\r\n\r\n", "HTTP/1.1 403 Forbidden");
int size = strlen(echo_buffer);
sprintf(buffer, "%s%d\r\n\r\n", "HTTP/1.1 200 OK\r\nContent-Length: ", size);
send(socket, buffer, strlen(buffer), 0);
cout << "402 " << path << endl;
send(socket, echo_buffer, size, 0);
continue;
}
FILE *file = fopen(path, "w+");