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
497 typedef void (*lws_hdr_custom_fe_cb_t)(
const char *name,
int nlen,
void *opaque);
514 LWS_VISIBLE LWS_EXTERN
int
538 LWS_VISIBLE LWS_EXTERN
int
558 LWS_VISIBLE LWS_EXTERN
const char *
579 #define LWSAHH_CODE_MASK ((1 << 16) - 1)
580 #define LWSAHH_FLAG_NO_SERVER_NAME (1 << 30)
596 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
598 unsigned int code,
unsigned char **p,
612 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
614 const unsigned char *value,
int length,
615 unsigned char **p,
unsigned char *end);
629 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
631 const unsigned char *value,
int length,
632 unsigned char **p,
unsigned char *end);
643 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
645 lws_filepos_t content_length,
646 unsigned char **p,
unsigned char *end);
656 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
671 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
673 unsigned char **p,
unsigned char *end);
675 #define LWS_ILLEGAL_HTTP_CONTENT_LEN ((lws_filepos_t)-1ll)
703 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
705 const char *content_type, lws_filepos_t content_len,
706 unsigned char **p,
unsigned char *end);
717 LWSHUMETH_COLON_PATH,
733 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
759 LWS_VISIBLE LWS_EXTERN
const char *
760 lws_urlencode(
char *escaped,
const char *
string,
int len);
783 LWS_VISIBLE LWS_EXTERN
int
784 lws_urldecode(
char *
string,
const char *escaped,
int len);
797 LWS_VISIBLE LWS_EXTERN
int
798 lws_http_date_render_from_unix(
char *buf,
size_t len,
const time_t *t);
810 LWS_VISIBLE LWS_EXTERN
int
811 lws_http_date_parse_unix(
const char *b,
size_t len, time_t *t);
831 LWS_VISIBLE LWS_EXTERN
int
832 lws_http_check_retry_after(
struct lws *wsi, lws_usec_t *us_interval_in_out);
843 LWS_VISIBLE LWS_EXTERN
int
844 lws_return_http_status(
struct lws *wsi,
unsigned int code,
845 const char *html_body);
859 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
860 lws_http_redirect(
struct lws *wsi,
int code,
const unsigned char *loc,
int len,
861 unsigned char **p,
unsigned char *end);
871 LWS_VISIBLE LWS_EXTERN
int LWS_WARN_UNUSED_RESULT
872 lws_http_transaction_completed(
struct lws *wsi);
881 LWS_VISIBLE LWS_EXTERN
int
882 lws_http_headers_detach(
struct lws *wsi);
892 LWS_VISIBLE LWS_EXTERN
int
893 lws_http_mark_sse(
struct lws *wsi);
910 LWS_VISIBLE LWS_EXTERN
int
911 lws_h2_client_stream_long_poll_rxonly(
struct lws *wsi);
938 LWS_VISIBLE LWS_EXTERN
int
939 lws_http_compression_apply(
struct lws *wsi,
const char *name,
940 unsigned char **p,
unsigned char *end,
char decomp);
950 LWS_VISIBLE LWS_EXTERN
int
951 lws_http_is_redirected_to_get(
struct lws *wsi);
970 LWS_VISIBLE LWS_EXTERN
int
971 lws_http_cookie_get(
struct lws *wsi,
const char *name,
char *buf,
size_t *max);
981 #define lws_http_client_http_resp_is_error(code) (!(code < 400))
1008 #define LWS_H2_STREAM_SID -1
1009 LWS_VISIBLE LWS_EXTERN
int
1010 lws_h2_update_peer_txcredit(
struct lws *wsi,
unsigned int sid,
int bump);
1024 LWS_VISIBLE LWS_EXTERN
int
1025 lws_h2_get_peer_txcredit_estimate(
struct lws *wsi);
Definition: lws-context-vhost.h:1293
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