How to abort a long POST request?
Posted: Fri May 15, 2015 10:41 am
Is there a clean way to abort a long POST request? E.g. a request where the cgi determines in the first call that the POST is invalid and an error should be returned? I put the following crappy code into my handler and am wondering whether something else could work better:
It seems to me that as soon as the handler returns HTTPD_CGI_DONE it should not be called again, but that's not what happens.
Code: Select all
int ICACHE_FLASH_ATTR cgiUploadFirmware(HttpdConnData *connData) {
int offset = connData->post->received - connData->post->buffLen;
if (offset == 0) {
connData->cgiPrivData = NULL;
} else if (connData->cgiPrivData != NULL) {
// we have an error condition, do nothing
return HTTPD_CGI_DONE;
}
...
// return an error if there is one
if (err != NULL) {
os_printf("Error %d: %s\n", code, err);
...
connData->cgiPrivData = (void *)1;
return HTTPD_CGI_DONE;
}
It seems to me that as soon as the handler returns HTTPD_CGI_DONE it should not be called again, but that's not what happens.