...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
static void HTTPc_RespBodyHook (HTTPc_CONN_OBJ *p_conn, HTTPc_REQ_OBJ *p_req, HTTP_CONTENT_TYPE content_type, void *p_data, CPU_INT32U data_len, CPU_BOOLEAN last_chunk) { FS_FILE *p_file; FS_FLAGS fs_flags; CPU_SIZE_T size_wr; CPU_SIZE_T size_wr_tot; CPU_BOOLEAN is_open; FS_ERR err_fs; is_open = FSFile_IsOpen("\\index.html", &fs_flags, &err_fs); if (err_fs != FS_ERR_NONE) { return; } if (is_open == DEF_NO) { fs_flags = 0; DEF_BIT_SET(fs_flags, FS_FILE_ACCESS_MODE_WR); DEF_BIT_SET(fs_flags, FS_FILE_ACCESS_MODE_CREATE); DEF_BIT_SET(fs_flags, FS_FILE_ACCESS_MODE_TRUNCATE); p_file = FSFile_Open("index.html", fs_flags, &err_fs); if (err_fs != FS_ERR_NONE) { return; } } switch (content_type) { case HTTP_CONTENT_TYPE_HTML: if (p_data != DEF_NULL) { size_wr = 0; size_wr_tot = 0; while (size_wr < data_len) { size_wr = FSFile_Wr(p_file, p_data, data_len, &err_fs); if (err_fs != FS_ERR_NONE) { return; } size_wr_tot += size_wr; } } break; case HTTP_CONTENT_TYPE_OCTET_STREAM: case HTTP_CONTENT_TYPE_PDF: case HTTP_CONTENT_TYPE_ZIP: case HTTP_CONTENT_TYPE_GIF: case HTTP_CONTENT_TYPE_JPEG: case HTTP_CONTENT_TYPE_PNG: case HTTP_CONTENT_TYPE_JS: case HTTP_CONTENT_TYPE_PLAIN: case HTTP_CONTENT_TYPE_CSS: case HTTP_CONTENT_TYPE_JSON: default: break; } if (last_chunk == DEF_YES) { FSFile_Close(p_file, &err_fs); } } |
...