libwebsockets
Lightweight C library for HTML5 websockets
HTTP

Modules

 Form Parsing
 
 HTML Chunked Substitution
 
 HTTP File transfer
 
 HTTP headers: create
 
 HTTP headers: read
 
 Urlencode and Urldecode
 

Data Structures

struct  lws_process_html_args
 
struct  lws_tokens
 

Enumerations

enum  http_status {
  HTTP_STATUS_CONTINUE = 100, HTTP_STATUS_OK = 200, HTTP_STATUS_NO_CONTENT = 204, HTTP_STATUS_PARTIAL_CONTENT = 206,
  HTTP_STATUS_MOVED_PERMANENTLY = 301, HTTP_STATUS_FOUND = 302, HTTP_STATUS_SEE_OTHER = 303, HTTP_STATUS_NOT_MODIFIED = 304,
  HTTP_STATUS_BAD_REQUEST = 400, HTTP_STATUS_UNAUTHORIZED, HTTP_STATUS_PAYMENT_REQUIRED, HTTP_STATUS_FORBIDDEN,
  HTTP_STATUS_NOT_FOUND, HTTP_STATUS_METHOD_NOT_ALLOWED, HTTP_STATUS_NOT_ACCEPTABLE, HTTP_STATUS_PROXY_AUTH_REQUIRED,
  HTTP_STATUS_REQUEST_TIMEOUT, HTTP_STATUS_CONFLICT, HTTP_STATUS_GONE, HTTP_STATUS_LENGTH_REQUIRED,
  HTTP_STATUS_PRECONDITION_FAILED, HTTP_STATUS_REQ_ENTITY_TOO_LARGE, HTTP_STATUS_REQ_URI_TOO_LONG, HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE,
  HTTP_STATUS_REQ_RANGE_NOT_SATISFIABLE, HTTP_STATUS_EXPECTATION_FAILED, HTTP_STATUS_INTERNAL_SERVER_ERROR = 500, HTTP_STATUS_NOT_IMPLEMENTED,
  HTTP_STATUS_BAD_GATEWAY, HTTP_STATUS_SERVICE_UNAVAILABLE, HTTP_STATUS_GATEWAY_TIMEOUT, HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED
}
 

Functions

LWS_VISIBLE LWS_EXTERN int lws_return_http_status (struct lws *wsi, unsigned int code, const char *html_body)
 
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_http_redirect (struct lws *wsi, int code, const unsigned char *loc, int len, unsigned char **p, unsigned char *end)
 
LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_http_transaction_completed (struct lws *wsi)
 

Detailed Description

Modules related to handling HTTP

Function Documentation

◆ lws_http_redirect()

LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_http_redirect ( struct lws *  wsi,
int  code,
const unsigned char *  loc,
int  len,
unsigned char **  p,
unsigned char *  end 
)

#include <lib/libwebsockets.h>

lws_http_redirect() - write http redirect into buffer

Parameters
wsiwebsocket connection
codeHTTP response code (eg, 301)
locwhere to redirect to
lenlength of loc
ppointer current position in buffer (updated as we write)
endpointer to end of buffer

◆ lws_http_transaction_completed()

LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT lws_http_transaction_completed ( struct lws *  wsi)

#include <lib/libwebsockets.h>

lws_http_transaction_completed() - wait for new http transaction or close

Parameters
wsiwebsocket connection
 Returns 1 if the HTTP connection must close now
 Returns 0 and resets connection to wait for new HTTP header /
   transaction if possible

◆ lws_return_http_status()

LWS_VISIBLE LWS_EXTERN int lws_return_http_status ( struct lws *  wsi,
unsigned int  code,
const char *  html_body 
)

#include <lib/libwebsockets.h>

lws_return_http_status() - Return simple http status

Parameters
wsiWebsocket instance (available from user callback)
codeStatus index, eg, 404
html_bodyUser-readable HTML description < 1KB, or NULL
 Helper to report HTTP errors back to the client cleanly and
 consistently