27 #define LWS_RECOMMENDED_MIN_HEADER_SPACE 2048
53 LWS_VISIBLE LWS_EXTERN
const char *
54 lws_get_mimetype(
const char *file,
const struct lws_http_mount *m);
74 LWS_VISIBLE LWS_EXTERN
int
75 lws_serve_http_file(
struct lws *wsi,
const char *file,
const char *content_type,
76 const char *other_headers,
int other_headers_len);
78 LWS_VISIBLE LWS_EXTERN
int
79 lws_serve_http_file_fragment(
struct lws *wsi);
84 HTTP_STATUS_CONTINUE = 100,
87 HTTP_STATUS_NO_CONTENT = 204,
88 HTTP_STATUS_PARTIAL_CONTENT = 206,
90 HTTP_STATUS_MOVED_PERMANENTLY = 301,
91 HTTP_STATUS_FOUND = 302,
92 HTTP_STATUS_SEE_OTHER = 303,
93 HTTP_STATUS_NOT_MODIFIED = 304,
95 HTTP_STATUS_BAD_REQUEST = 400,
96 HTTP_STATUS_UNAUTHORIZED,
97 HTTP_STATUS_PAYMENT_REQUIRED,
98 HTTP_STATUS_FORBIDDEN,
99 HTTP_STATUS_NOT_FOUND,
100 HTTP_STATUS_METHOD_NOT_ALLOWED,
101 HTTP_STATUS_NOT_ACCEPTABLE,
102 HTTP_STATUS_PROXY_AUTH_REQUIRED,
103 HTTP_STATUS_REQUEST_TIMEOUT,
104 HTTP_STATUS_CONFLICT,
106 HTTP_STATUS_LENGTH_REQUIRED,
107 HTTP_STATUS_PRECONDITION_FAILED,
108 HTTP_STATUS_REQ_ENTITY_TOO_LARGE,
109 HTTP_STATUS_REQ_URI_TOO_LONG,
110 HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE,
111 HTTP_STATUS_REQ_RANGE_NOT_SATISFIABLE,
112 HTTP_STATUS_EXPECTATION_FAILED,
114 HTTP_STATUS_INTERNAL_SERVER_ERROR = 500,
115 HTTP_STATUS_NOT_IMPLEMENTED,
116 HTTP_STATUS_BAD_GATEWAY,
117 HTTP_STATUS_SERVICE_UNAVAILABLE,
118 HTTP_STATUS_GATEWAY_TIMEOUT,
119 HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED,
141 typedef const char *(*lws_process_html_state_cb)(
void *data,
int index);
159 LWS_VISIBLE LWS_EXTERN
int
215 enum lws_token_indexes {
218 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_HTTP_HEADERS_ALL)
219 WSI_TOKEN_OPTIONS_URI,
222 WSI_TOKEN_CONNECTION,
225 #if defined(LWS_ROLE_WS) || defined(LWS_HTTP_HEADERS_ALL)
229 #if defined(LWS_ROLE_WS) || defined(LWS_HTTP_HEADERS_ALL)
230 WSI_TOKEN_EXTENSIONS,
238 #if defined(LWS_ROLE_H2) || defined(LWS_HTTP_HEADERS_ALL)
239 WSI_TOKEN_HTTP2_SETTINGS,
241 WSI_TOKEN_HTTP_ACCEPT,
242 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_HTTP_HEADERS_ALL)
243 WSI_TOKEN_HTTP_AC_REQUEST_HEADERS,
245 WSI_TOKEN_HTTP_IF_MODIFIED_SINCE,
246 WSI_TOKEN_HTTP_IF_NONE_MATCH,
247 WSI_TOKEN_HTTP_ACCEPT_ENCODING,
248 WSI_TOKEN_HTTP_ACCEPT_LANGUAGE,
249 WSI_TOKEN_HTTP_PRAGMA,
250 WSI_TOKEN_HTTP_CACHE_CONTROL,
251 WSI_TOKEN_HTTP_AUTHORIZATION,
252 WSI_TOKEN_HTTP_COOKIE,
253 WSI_TOKEN_HTTP_CONTENT_LENGTH,
254 WSI_TOKEN_HTTP_CONTENT_TYPE,
256 WSI_TOKEN_HTTP_RANGE,
257 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_ROLE_H2) || defined(LWS_HTTP_HEADERS_ALL)
258 WSI_TOKEN_HTTP_REFERER,
260 #if defined(LWS_ROLE_WS) || defined(LWS_HTTP_HEADERS_ALL)
265 #if defined(LWS_ROLE_H2) || defined(LWS_HTTP_HEADERS_ALL)
266 WSI_TOKEN_HTTP_COLON_AUTHORITY,
267 WSI_TOKEN_HTTP_COLON_METHOD,
268 WSI_TOKEN_HTTP_COLON_PATH,
269 WSI_TOKEN_HTTP_COLON_SCHEME,
270 WSI_TOKEN_HTTP_COLON_STATUS,
273 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_ROLE_H2) || defined(LWS_HTTP_HEADERS_ALL)
274 WSI_TOKEN_HTTP_ACCEPT_CHARSET,
276 WSI_TOKEN_HTTP_ACCEPT_RANGES,
277 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_ROLE_H2) || defined(LWS_HTTP_HEADERS_ALL)
278 WSI_TOKEN_HTTP_ACCESS_CONTROL_ALLOW_ORIGIN,
281 WSI_TOKEN_HTTP_ALLOW,
282 WSI_TOKEN_HTTP_CONTENT_DISPOSITION,
283 WSI_TOKEN_HTTP_CONTENT_ENCODING,
284 WSI_TOKEN_HTTP_CONTENT_LANGUAGE,
285 WSI_TOKEN_HTTP_CONTENT_LOCATION,
286 WSI_TOKEN_HTTP_CONTENT_RANGE,
288 WSI_TOKEN_HTTP_EXPECT,
289 WSI_TOKEN_HTTP_EXPIRES,
291 WSI_TOKEN_HTTP_IF_MATCH,
292 WSI_TOKEN_HTTP_IF_RANGE,
293 WSI_TOKEN_HTTP_IF_UNMODIFIED_SINCE,
294 WSI_TOKEN_HTTP_LAST_MODIFIED,
296 WSI_TOKEN_HTTP_LOCATION,
297 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_ROLE_H2) || defined(LWS_HTTP_HEADERS_ALL)
298 WSI_TOKEN_HTTP_MAX_FORWARDS,
299 WSI_TOKEN_HTTP_PROXY_AUTHENTICATE,
300 WSI_TOKEN_HTTP_PROXY_AUTHORIZATION,
302 WSI_TOKEN_HTTP_REFRESH,
303 WSI_TOKEN_HTTP_RETRY_AFTER,
304 WSI_TOKEN_HTTP_SERVER,
305 WSI_TOKEN_HTTP_SET_COOKIE,
306 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_ROLE_H2) || defined(LWS_HTTP_HEADERS_ALL)
307 WSI_TOKEN_HTTP_STRICT_TRANSPORT_SECURITY,
309 WSI_TOKEN_HTTP_TRANSFER_ENCODING,
310 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_ROLE_H2) || defined(LWS_HTTP_HEADERS_ALL)
311 WSI_TOKEN_HTTP_USER_AGENT,
314 WSI_TOKEN_HTTP_WWW_AUTHENTICATE,
316 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_HTTP_HEADERS_ALL)
319 WSI_TOKEN_DELETE_URI,
322 WSI_TOKEN_HTTP_URI_ARGS,
323 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_HTTP_HEADERS_ALL)
325 WSI_TOKEN_HTTP_X_REAL_IP,
328 WSI_TOKEN_X_FORWARDED_FOR,
331 #if defined(LWS_WITH_HTTP_UNCOMMON_HEADERS) || defined(LWS_ROLE_H2) || defined(LWS_HTTP_HEADERS_ALL)
333 WSI_TOKEN_REPLAY_NONCE,
335 #if defined(LWS_ROLE_H2) || defined(LWS_HTTP_HEADERS_ALL)
336 WSI_TOKEN_COLON_PROTOCOL,
338 WSI_TOKEN_X_AUTH_TOKEN,
339 WSI_TOKEN_DSS_SIGNATURE,
346 _WSI_TOKEN_CLIENT_SENT_PROTOCOLS,
347 _WSI_TOKEN_CLIENT_PEER_ADDRESS,
348 _WSI_TOKEN_CLIENT_URI,
349 _WSI_TOKEN_CLIENT_HOST,
350 _WSI_TOKEN_CLIENT_ORIGIN,
351 _WSI_TOKEN_CLIENT_METHOD,
352 _WSI_TOKEN_CLIENT_IFACE,
353 _WSI_TOKEN_CLIENT_ALPN,
360 #if defined(LWS_WITH_CUSTOM_HEADERS) || defined(LWS_HTTP_HEADERS_ALL)
361 WSI_TOKEN_UNKNOWN_VALUE_PART,
364 WSI_TOKEN_SKIPPING_SAW_CR,
365 WSI_PARSING_COMPLETE,
366 WSI_INIT_TOKEN_MUXURL,
373 enum lws_h2_settings {
374 H2SET_HEADER_TABLE_SIZE = 1,
376 H2SET_MAX_CONCURRENT_STREAMS,
377 H2SET_INITIAL_WINDOW_SIZE,
378 H2SET_MAX_FRAME_SIZE,
379 H2SET_MAX_HEADER_LIST_SIZE,
381 H2SET_ENABLE_CONNECT_PROTOCOL,
391 LWS_VISIBLE LWS_EXTERN
const unsigned char *
402 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
414 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
432 LWS_VISIBLE LWS_EXTERN
int
433 lws_hdr_copy(
struct lws *wsi,
char *dest,
int len,
enum lws_token_indexes h);
452 LWS_VISIBLE LWS_EXTERN
int
454 enum lws_token_indexes h,
int frag_idx);
472 LWS_VISIBLE LWS_EXTERN
int
493 LWS_VISIBLE LWS_EXTERN
int
520 LWS_VISIBLE LWS_EXTERN
int
540 LWS_VISIBLE LWS_EXTERN
const char *
561 #define LWSAHH_CODE_MASK ((1 << 16) - 1)
562 #define LWSAHH_FLAG_NO_SERVER_NAME (1 << 30)
578 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
580 unsigned int code,
unsigned char **p,
594 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
596 const unsigned char *value,
int length,
597 unsigned char **p,
unsigned char *end);
611 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
613 const unsigned char *value,
int length,
614 unsigned char **p,
unsigned char *end);
625 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
627 lws_filepos_t content_length,
628 unsigned char **p,
unsigned char *end);
638 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
653 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
655 unsigned char **p,
unsigned char *end);
657 #define LWS_ILLEGAL_HTTP_CONTENT_LEN ((lws_filepos_t)-1ll)
685 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
687 const char *content_type, lws_filepos_t content_len,
688 unsigned char **p,
unsigned char *end);
699 LWSHUMETH_COLON_PATH,
715 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
741 LWS_VISIBLE LWS_EXTERN
const char *
742 lws_urlencode(
char *escaped,
const char *
string,
int len);
765 LWS_VISIBLE LWS_EXTERN
int
766 lws_urldecode(
char *
string,
const char *escaped,
int len);
779 LWS_VISIBLE LWS_EXTERN
int
780 lws_http_date_render_from_unix(
char *buf,
size_t len,
const time_t *t);
792 LWS_VISIBLE LWS_EXTERN
int
793 lws_http_date_parse_unix(
const char *b,
size_t len, time_t *t);
813 LWS_VISIBLE LWS_EXTERN
int
814 lws_http_check_retry_after(
struct lws *wsi, lws_usec_t *us_interval_in_out);
825 LWS_VISIBLE LWS_EXTERN
int
826 lws_return_http_status(
struct lws *wsi,
unsigned int code,
827 const char *html_body);
841 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
842 lws_http_redirect(
struct lws *wsi,
int code,
const unsigned char *loc,
int len,
843 unsigned char **p,
unsigned char *end);
853 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
854 lws_http_transaction_completed(
struct lws *wsi);
863 LWS_VISIBLE LWS_EXTERN
int
864 lws_http_headers_detach(
struct lws *wsi);
874 LWS_VISIBLE LWS_EXTERN
int
875 lws_http_mark_sse(
struct lws *wsi);
892 LWS_VISIBLE LWS_EXTERN
int
893 lws_h2_client_stream_long_poll_rxonly(
struct lws *wsi);
920 LWS_VISIBLE LWS_EXTERN
int
921 lws_http_compression_apply(
struct lws *wsi,
const char *name,
922 unsigned char **p,
unsigned char *end,
char decomp);
932 LWS_VISIBLE LWS_EXTERN
int
933 lws_http_is_redirected_to_get(
struct lws *wsi);
952 LWS_VISIBLE LWS_EXTERN
int
953 lws_http_cookie_get(
struct lws *wsi,
const char *name,
char *buf,
size_t *max);
963 #define lws_http_client_http_resp_is_error(code) (!(code < 400))
990 #define LWS_H2_STREAM_SID -1
991 LWS_VISIBLE LWS_EXTERN
int
992 lws_h2_update_peer_txcredit(
struct lws *wsi,
unsigned int sid,
int bump);
1006 LWS_VISIBLE LWS_EXTERN
int
1007 lws_h2_get_peer_txcredit_estimate(
struct lws *wsi);
Definition: lws-context-vhost.h:1289
Definition: lws-http.h:132
int chunked
Definition: lws-http.h:137
char * p
Definition: lws-http.h:133
int len
Definition: lws-http.h:134
int max_len
Definition: lws-http.h:135
Definition: lws-http.h:143
const char *const * vars
Definition: lws-http.h:148
int pos
Definition: lws-http.h:146
lws_process_html_state_cb replace
Definition: lws-http.h:151
char swallow[16]
Definition: lws-http.h:145
int count_vars
Definition: lws-http.h:149
char * start
Definition: lws-http.h:144
void * data
Definition: lws-http.h:147
Definition: lws-http.h:369
unsigned short token_limit[WSI_TOKEN_COUNT]
Definition: lws-http.h:370
Definition: lws-http.h:204
int len
Definition: lws-http.h:206
unsigned char * token
Definition: lws-http.h:205