Lines Matching defs:file
2 * @file
32 * This file is part of the lwIP TCP/IP stack.
45 * <!--#tag--> in any file whose extension is .shtml, .shtm or .ssi with
56 * each file stored in the file system. By defining LWIP_HTTPD_DYNAMIC_HEADERS in
58 * headers automatically based on the extension of the file being served. If
59 * this mode is used, be careful to ensure that the file system image used
87 * The list of supported file types is quite short, so if makefsdata complains
135 /** tcp_write does not have to copy data when sent from rom-file-system directly */
138 /** Default: dynamic headers are sent from ROM (non-dynamic headers are handled like file data) */
178 /* Filename for response file to send when POST is finished or
185 * requested file.
247 const char *file; /* Pointer to first unsent byte in buf. */
256 int buf_len; /* Size of file read buffer, buf. */
311 static err_t http_init_file(struct http_state *hs, struct fs_file *file, int is_09, const char *uri, u8_t tag_check, char *params);
475 * Also frees the file data if dynamic.
484 LWIP_DEBUGF(HTTPD_DEBUG_TIMING, ("httpd: needed %"U32_F" ms to send file of %d bytes -> %"U32_F" bytes/sec\n",
511 * Also frees the file data if dynamic.
651 /** End of file: either close the connection (Connection: close) or
652 * close the file (Connection: keep-alive)
749 * Insert a tag (found in an shtml in the form of "<!--#tagname-->" into the file.
855 /* Is this a normal file or the special case we use to send back the
894 /* Get a pointer to the file extension. We find this by looking for the
920 /* Does the URL passed have any file extension? If not, we assume it
938 /* No - use the default, plain text file type. */
956 if (hs->ssi == NULL) /* @todo: get maximum file length from SSI */
1062 if ((hs->hdr_index >= NUM_FILE_HDR_STRINGS) && (hs->file == NULL)) {
1076 * more headers to send, but we do have file data to send, drop through
1077 * to try to send some file data too. */
1078 if ((hs->hdr_index < NUM_FILE_HDR_STRINGS) || !hs->file) {
1086 /** Sub-function of http_send(): end-of-file (or block) is reached,
1087 * either close the file or read the next block (if supported).
1089 * @returns: 0 if the file is finished or no data has been read
1090 * 1 if the file is not finished and data has been read
1103 /* Do we have a valid file handle? */
1111 /* We reached the end of the file so this request is done. */
1112 LWIP_DEBUGF(HTTPD_DEBUG, ("End of file.\n"));
1150 /* Read a block of data from the file. */
1163 /* We reached the end of the file so this request is done.
1164 * @todo: close here for HTTP/1.1 when reading file fails */
1165 LWIP_DEBUGF(HTTPD_DEBUG, ("End of file.\n"));
1173 hs->file = hs->buf;
1198 /* We are not processing an SHTML file so no tag checking is necessary.
1199 * Just send the data as we received it from the file. */
1202 err = http_write(pcb, hs->file, &len, HTTP_IS_DATA_VOLATILE(hs));
1205 hs->file += len;
1228 /* We are processing an SHTML file so need to scan for tags and replace
1230 * straddle the boundary of two blocks read from the file and we may also
1237 if (ssi->parsed > hs->file) {
1238 len = (u16_t)LWIP_MIN(ssi->parsed - hs->file, 0xffff);
1240 err = http_write(pcb, hs->file, &len, HTTP_IS_DATA_VOLATILE(hs));
1243 hs->file += len;
1306 (ssi->parsed - hs->file < ssi->tag_index)) {
1311 hs->file += ssi->parsed - hs->file;
1312 hs->left -= ssi->parsed - hs->file;
1313 ssi->tag_end = hs->file;
1423 if (ssi->tag_end > hs->file) {
1426 len = (u16_t)LWIP_MIN(ssi->tag_end - hs->file, 0xffff);
1429 len = (u16_t)LWIP_MIN(ssi->tag_started - hs->file, 0xffff);
1432 err = http_write(pcb, hs->file, &len, HTTP_IS_DATA_VOLATILE(hs));
1436 if (ssi->tag_started <= hs->file) {
1441 hs->file += len;
1458 * from the file prior to the insert point or the insert string itself.
1461 /* Do we have any remaining file data to send from the buffer prior
1463 if (ssi->tag_end > hs->file) {
1466 len = (u16_t)LWIP_MIN(ssi->tag_end - hs->file, 0xffff);
1468 LWIP_ASSERT("hs->started >= hs->file", ssi->tag_started >= hs->file);
1470 len = (u16_t)LWIP_MIN(ssi->tag_started - hs->file, 0xffff);
1473 err = http_write(pcb, hs->file, &len, HTTP_IS_DATA_VOLATILE(hs));
1480 if (ssi->tag_started <= hs->file) {
1485 hs->file += len;
1540 * file data to send so send it now. In TAG_SENDING state, we've already
1542 if ((ssi->tag_state != TAG_SENDING) && (ssi->parsed > hs->file)) {
1547 len = (u16_t)(ssi->tag_started - hs->file);
1554 len = (u16_t)LWIP_MIN(ssi->parsed - hs->file, 0xffff);
1557 err = http_write(pcb, hs->file, &len, HTTP_IS_DATA_VOLATILE(hs));
1560 hs->file += len;
1594 /* Check if we are allowed to read from this file.
1602 /* Do we have any more header data to send for this file? */
1613 /* Have we run out of file data to send? If so, we need to read the next
1614 * block from the file. */
1631 /* We reached the end of the file so this request is done.
1633 LWIP_DEBUGF(HTTPD_DEBUG, ("End of file.\n"));
1642 /** Initialize a http connection with a file to send for an error message
1646 * @return ERR_OK if file was found and hs has been initialized correctly
1682 * Get the file struct for a 404 error page.
1683 * Tries some file names and returns NULL if none found.
1685 * @param uri pointer that receives the actual file name URI
1686 * @return file struct for the error page or NULL no matching file was found
1741 * @return ERR_OK if passed successfully, another err_t if the response file
1870 /* return file passed from application */
1936 /** Try to send more data if file has been blocked before
1985 if ((hs->handle != NULL) || (hs->file != NULL)) {
1986 LWIP_DEBUGF(HTTPD_DEBUG, ("Received data while sending a file\n"));
1987 /* already sending a file */
2142 /* Check if SSI should be parsed for this file/URL
2149 http_uri_is_ssi(struct fs_file *file, const char *uri)
2153 if (file != NULL) {
2154 /* See if we have been asked for an shtml file and, if so,
2182 /** Try to find the file specified by uri and, if found, initialize hs
2188 * @return ERR_OK if file was found and hs has been initialized correctly
2195 struct fs_file *file = NULL;
2207 /* Have we been asked for the default file (in root or a directory) ? */
2243 file = &hs->file_handle;
2252 if (file == NULL) {
2253 /* No - we've been asked for a specific file. */
2285 file = &hs->file_handle;
2287 file = http_get_404_file(hs, &uri);
2290 if (file != NULL) {
2291 if (file->flags & FS_FILE_FLAGS_SSI) {
2295 tag_check = http_uri_is_ssi(file, uri);
2301 if (file == NULL) {
2303 file = http_get_404_file(hs, &uri);
2305 return http_init_file(hs, file, is_09, uri, tag_check, params);
2308 /** Initialize a http connection with a file to send (if found).
2312 * @param file file structure to send (or NULL if not found)
2317 * @return ERR_OK if file was found and hs has been initialized correctly
2321 http_init_file(struct http_state *hs, struct fs_file *file, int is_09, const char *uri,
2327 if (file != NULL) {
2328 /* file opened, initialise struct http_state */
2330 /* If dynamic read is disabled, file data must be in one piece and available now */
2331 LWIP_ASSERT("file->data != NULL", file->data != NULL);
2340 ssi->parsed = file->data;
2341 ssi->parse_left = file->len;
2342 ssi->tag_end = file->data;
2349 hs->handle = file;
2362 httpd_cgi_handler(file, uri, count, http_cgi_params, http_cgi_param_vals
2364 , file->state
2371 hs->file = file->data;
2372 LWIP_ASSERT("File length must be positive!", (file->len >= 0));
2374 if (file->is_custom_file && (file->data == NULL)) {
2375 /* custom file, need to read data first (via fs_read_custom) */
2380 hs->left = (u32_t)file->len;
2387 LWIP_ASSERT("HTTP headers not included in file system",
2394 char *file_start = lwip_strnstr(hs->file, CRLF CRLF, hs->left);
2396 int diff = file_start + 4 - hs->file;
2397 hs->file += diff;
2404 hs->file = NULL;
2409 /* Determine the HTTP headers to send based on the file extension of
2479 * If the last portion of a file has not been sent in 2 seconds, close.
2511 /* If this connection has a file open, try to send some more data. If
2597 LWIP_DEBUGF(HTTPD_DEBUG | LWIP_DBG_TRACE, ("http_recv: data %p len %"S32_F"\n", (const void *)hs->file, hs->left));