|
@@ -48,7 +48,7 @@ static void HTTP_ForceUserLogout(uint8_t user_id);
|
|
void LogoutTimerCallback(TimerHandle_t pxTimer);
|
|
void LogoutTimerCallback(TimerHandle_t pxTimer);
|
|
void LoginTimerCallback(TimerHandle_t pxTimer);
|
|
void LoginTimerCallback(TimerHandle_t pxTimer);
|
|
int HTTP_ChangeUserPwd(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
int HTTP_ChangeUserPwd(char *bufIn, char *bufOut, uint16_t lenBufIn, uint16_t *lenBufOut);
|
|
-void send_file(char *filename, char *pnonmatch, struct fs_file *file);
|
|
|
|
|
|
+char* send_file(char *filename, char *pnonmatch, struct fs_file *file, uint16_t *Len);
|
|
static uint32_t Parse_Header(char *data, uint32_t len, const char *field, uint32_t flen, char *value);
|
|
static uint32_t Parse_Header(char *data, uint32_t len, const char *field, uint32_t flen, char *value);
|
|
bool GetFileName(char *inStr, char *fileName, uint8_t *fileNameLen);
|
|
bool GetFileName(char *inStr, char *fileName, uint8_t *fileNameLen);
|
|
|
|
|
|
@@ -1988,7 +1988,7 @@ char* AuthenticatedTrueRoutine(uint16_t* sendLen)
|
|
char *DataOffset;
|
|
char *DataOffset;
|
|
char *ptr;
|
|
char *ptr;
|
|
|
|
|
|
- if (strncmp(receiveBuf, "GET /main.css", 13) == 0) // +
|
|
|
|
|
|
+ /* if (strncmp(receiveBuf, "GET /main.css", 13) == 0) // +
|
|
{
|
|
{
|
|
fs_open("/main.css", &file);
|
|
fs_open("/main.css", &file);
|
|
*sendLen = file.len;
|
|
*sendLen = file.len;
|
|
@@ -2050,7 +2050,7 @@ char* AuthenticatedTrueRoutine(uint16_t* sendLen)
|
|
*sendLen = file.len;
|
|
*sendLen = file.len;
|
|
return file.data;
|
|
return file.data;
|
|
}
|
|
}
|
|
- else if (strncmp(receiveBuf, "GET /getJson.cgi", 16) == 0) // +
|
|
|
|
|
|
+ else*/ if (strncmp(receiveBuf, "GET /getJson.cgi", 16) == 0) // +
|
|
{
|
|
{
|
|
HTTP_GetParamsPage1(sendBuf);
|
|
HTTP_GetParamsPage1(sendBuf);
|
|
*sendLen = strlen(sendBuf);
|
|
*sendLen = strlen(sendBuf);
|
|
@@ -2361,6 +2361,25 @@ char* AuthenticatedTrueRoutine(uint16_t* sendLen)
|
|
HTTP_Prodate(receiveBuf, sendBuf, receivedBufLen, sendLen);
|
|
HTTP_Prodate(receiveBuf, sendBuf, receivedBufLen, sendLen);
|
|
return sendBuf;
|
|
return sendBuf;
|
|
}
|
|
}
|
|
|
|
+ /* Check common GET request */
|
|
|
|
+ else if (strncmp(receiveBuf, "GET", 3) == 0) {
|
|
|
|
+ char filename[MAX_FILENAME_LEN];
|
|
|
|
+ char nonmatch[MAX_ETAG_LEN];
|
|
|
|
+ char *pnonmatch = NULL;
|
|
|
|
+ uint8_t len;
|
|
|
|
+
|
|
|
|
+ if (GetFileName(receiveBuf, filename, &len)) {
|
|
|
|
+ HTTP_UpdateUserLoginTime(user_id);
|
|
|
|
+
|
|
|
|
+ /* Parce If-Non_Match value */
|
|
|
|
+ uint8_t nonmatch_len = Parse_Header(receiveBuf, receivedBufLen, If_None_Match, 15, nonmatch);
|
|
|
|
+ if (nonmatch_len < MAX_ETAG_LEN && nonmatch_len > 0) {
|
|
|
|
+ DBG printf("If_None_Match: %s\r\n", nonmatch);
|
|
|
|
+ pnonmatch = nonmatch;
|
|
|
|
+ }
|
|
|
|
+ return send_file(filename, pnonmatch, &file, sendLen);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
else
|
|
else
|
|
{
|
|
{
|
|
HTTP_UpdateUserLoginTime(user_id);
|
|
HTTP_UpdateUserLoginTime(user_id);
|
|
@@ -2507,7 +2526,7 @@ void HTTP_SendLog(void)
|
|
* @param file: pointer to a fs_file struct
|
|
* @param file: pointer to a fs_file struct
|
|
* @retval
|
|
* @retval
|
|
*/
|
|
*/
|
|
-void send_file(char *filename, char *pnonmatch, struct fs_file *file)
|
|
|
|
|
|
+char* send_file(char *filename, char *pnonmatch, struct fs_file *file, uint16_t *Len)
|
|
{
|
|
{
|
|
int res = 0;
|
|
int res = 0;
|
|
char etag[MAX_ETAG_LEN];
|
|
char etag[MAX_ETAG_LEN];
|
|
@@ -2533,6 +2552,8 @@ void send_file(char *filename, char *pnonmatch, struct fs_file *file)
|
|
/* Send 304 code */
|
|
/* Send 304 code */
|
|
sprintf(sendBuf, HTTP_304_NOT_MODIFIED);
|
|
sprintf(sendBuf, HTTP_304_NOT_MODIFIED);
|
|
DBG printf(sendBuf);
|
|
DBG printf(sendBuf);
|
|
|
|
+ *Len = strlen(sendBuf);
|
|
|
|
+ return sendBuf;
|
|
//hs->file = sendBuf;
|
|
//hs->file = sendBuf;
|
|
//hs->left = strlen(sendBuf);
|
|
//hs->left = strlen(sendBuf);
|
|
}
|
|
}
|
|
@@ -2541,6 +2562,8 @@ void send_file(char *filename, char *pnonmatch, struct fs_file *file)
|
|
//DBG printf("%s\r\n\r\n", filename);
|
|
//DBG printf("%s\r\n\r\n", filename);
|
|
//hs->file = file->data;
|
|
//hs->file = file->data;
|
|
//hs->left = file->len;
|
|
//hs->left = file->len;
|
|
|
|
+ *Len = file->len;
|
|
|
|
+ return file->data;
|
|
}
|
|
}
|
|
|
|
|
|
//send_data(pcb, hs);
|
|
//send_data(pcb, hs);
|