Serial Parameters
BaudRate:
Data bits:

URLSimple_process Function: int URLSimple_process(URLHandler_Handle urlHandler, int method, const char * url, const char * urlArgs, int contentLength, int ssock) { int status = URLHandler_ENOTHANDLED; char *body = NULL; /* Body of HTTP response in process */ char *contentType = "text/html"; /* default is "text/plain", but can be overridden */ char *retString = NULL; /* String retrieved from server */ char *inputKey = NULL; /* Name of value to store in server */ char *inputValue = NULL; /* Value to store in server */ char argsToParse[MAX_DB_ENTRY_LEN]; int returnCode; /* HTTP response status code */ int retc; /* Error checking for internal funcs */ /* Determine the corresponding URL on the server */ if (strcmp(url, "/index.html") == 0) { if (method == URLHandler_GET) { body = "/get 'login.html': This is the login page."; returnCode = HTTP_SC_OK; status = URLHandler_EHANDLED; HTTPServer_sendSimpleResponse(ssock, returnCode, contentType, INDEX_SIZE, INDEX); } else if (method == URLHandler_POST) { inputValue = strtok(NULL, "="); retc = serverPost(inputKey, inputValue); if (retc == ERR_BAD_INPUT) { body = "Failed to POST. The data string is invalid."; returnCode = HTTP_SC_BAD_REQUEST; status = URLHandler_EERRORHANDLED; } else if (retc == ERR_DB_FULL) { body = "Database is full"; returnCode = HTTP_SC_SERVICE_UNAVAILABLE; status = URLHandler_EERRORHANDLED; } else { body = "Data string successfully posted to server."; returnCode = HTTP_SC_OK; status = URLHandler_EHANDLED; } } } else if(method == URLHandler_PATCH) { body = "PATCH is not handled by any handlers on this server."; returnCode = HTTP_SC_METHOD_NOT_ALLOWED; status = URLHandler_ENOTHANDLED; } else if(method == URLHandler_DELETE) { body = "DELETE is not handled by any handlers on this server."; returnCode = HTTP_SC_METHOD_NOT_ALLOWED; status = URLHandler_EERRORHANDLED; } if (status != URLHandler_ENOTHANDLED) { if (contentLength > 0) { char *buf; buf = malloc(contentLength); /* This is done to flush the socket */ (void) Ssock_recvall(ssock, buf, contentLength, 0); free(buf); } HTTPServer_sendSimpleResponse(ssock, returnCode, contentType, body ? strlen(body) : 0, body ? body : NULL); } return (status); }