1
0
Fork 0

Fixed issue when receiving by POST method.

yamux^2
Jose Marcial Vieira Bisneto 2017-10-12 20:08:21 -03:00
parent a315af8534
commit 4e556221bd
No known key found for this signature in database
GPG Key ID: 103E935E7E6E831E
1 changed files with 3 additions and 9 deletions

View File

@ -462,9 +462,6 @@ void *api_connection_thread (void *ptr)
goto quit; goto quit;
} }
// once we leave the building of the req struct, do we need to do more? This flag will tell us.
int further_processing_necessary = 0;
if (strncmp(req.buf + req.method, "GET", 3)==0) { if (strncmp(req.buf + req.method, "GET", 3)==0) {
if (strcmp (req.buf + req.path, "/")==0 || if (strcmp (req.buf + req.path, "/")==0 ||
strcmp (req.buf + req.path, "/webui")==0 || strcmp (req.buf + req.path, "/webui")==0 ||
@ -481,10 +478,7 @@ void *api_connection_thread (void *ptr)
} else { } else {
write_cstr (s, HTTP_500); write_cstr (s, HTTP_500);
} }
} else if (cstrstart(req.buf + req.path, API_V0_START)) { } else if (!cstrstart(req.buf + req.path, API_V0_START)) {
req.request = req.path + sizeof(API_V0_START) - 1;
further_processing_necessary = 1;
} else {
// TODO: handle download file here. // TODO: handle download file here.
// move out of the if to do further processing // move out of the if to do further processing
} }
@ -540,10 +534,10 @@ void *api_connection_thread (void *ptr)
// Unexpected??? // Unexpected???
libp2p_logger_error("api", "fail unexpected '%s'.\n", req.buf + req.method); libp2p_logger_error("api", "fail unexpected '%s'.\n", req.buf + req.method);
write_cstr (s, HTTP_500); write_cstr (s, HTTP_500);
further_processing_necessary = 0;
} }
if (further_processing_necessary) { if (cstrstart(req.buf + req.path, API_V0_START)) {
req.request = req.path + sizeof(API_V0_START) - 1;
// now do something with the request we have built // now do something with the request we have built
struct HttpRequest* http_request = api_build_http_request(&req); struct HttpRequest* http_request = api_build_http_request(&req);
if (http_request != NULL) { if (http_request != NULL) {