![]() |
libwebsockets
Lightweight C library for HTML5 websockets
|
Functions | |
LWS_VISIBLE LWS_EXTERN const char * | lws_get_mimetype (const char *file, const struct lws_http_mount *m) |
LWS_VISIBLE LWS_EXTERN int | lws_serve_http_file (struct lws *wsi, const char *file, const char *content_type, const char *other_headers, int other_headers_len) |
LWS_VISIBLE LWS_EXTERN int | lws_serve_http_file_fragment (struct lws *wsi) |
APIs for sending local files in response to HTTP requests
LWS_VISIBLE LWS_EXTERN const char* lws_get_mimetype | ( | const char * | file, |
const struct lws_http_mount * | m | ||
) |
#include <lib/libwebsockets.h>
lws_get_mimetype() - Determine mimetype to use from filename
file | filename |
m | NULL, or mount context |
This uses a canned list of known filetypes first, if no match and m is non-NULL, then tries a list of per-mount file suffix to mimtype mappings.
Returns either NULL or a pointer to the mimetype matching the file.
LWS_VISIBLE LWS_EXTERN int lws_serve_http_file | ( | struct lws * | wsi, |
const char * | file, | ||
const char * | content_type, | ||
const char * | other_headers, | ||
int | other_headers_len | ||
) |
#include <lib/libwebsockets.h>
lws_serve_http_file() - Send a file back to the client using http
wsi | Websocket instance (available from user callback) |
file | The file to issue over http |
content_type | The http content type, eg, text/html |
other_headers | NULL or pointer to header string |
other_headers_len | length of the other headers if non-NULL This function is intended to be called from the callback in response to http requests from the client. It allows the callback to issue local files down the http link in a single step. Returning <0 indicates error and the wsi should be closed. Returning >0 indicates the file was completely sent and lws_http_transaction_completed() called on the wsi (and close if != 0) ==0 indicates the file transfer is started and needs more service later, the wsi should be left alone. |