Prusa MINI Firmware overview
|
Go to the source code of this file.
Classes | |
class | LwIPClass |
class | IHeader |
Headers list. Creator is responsible to clean the values. More... | |
class | NumberHeader |
NumberHeader is for number headers like Content-Length. More... | |
class | ConstHeader |
ConstHeader only point to const chars defined in code. More... | |
class | DynamicsHeader |
DynamicsHeader store it's value to LwIP memory pool. More... | |
class | Environment |
Environment struct like as WSGI environment as possible could be. More... | |
struct | Message_t |
Message which must be returned from coroutine generator. More... | |
class | IResponse |
Macros | |
#define | MAX_HTTP_REQUEST 1024 |
LwIP WSAPI C/C++ implementation. More... | |
#define | METHOD_LENGTH 10 |
maximum method length (PROPPATCH) from WebDAV + \0 More... | |
#define | URI_LENGTH 64 |
maximum length of request uri More... | |
#define | lwsapi_dbg _dbg |
#define | lwsapi_error _dbg |
#define | lwsapi_free(arg) |
Typedefs | |
typedef IResponse::unique_ptr_t() | application_fn(Environment &env) |
application_fn typedef, which is called in tcp_recv callback. More... | |
typedef IHeader *(* | header_factory_fn) (const char *key, const char *value, size_t value_length) |
typedef IHeader *() | request_header_fn(const char *key, size_t key_length, const char *value, size_t value_length) |
This factory is used for parsing input headers. More... | |
Functions | |
IResponse::unique_ptr_t | application (Environment &env) |
Define of application functions. More... | |
IHeader * | const_header_factory (const char *key, const char *value, size_t value_length) |
Return new ConstHeader. More... | |
IHeader * | dynamics_header_factory (const char *key, const char *value, size_t value_length) |
Return new DynamicsHeader. More... | |
IHeader * | number_header_factory (const char *key, const char *value, size_t value_length) |
Response new NumberHeader. More... | |
IHeader * | request_header (const char *key, size_t key_length, const char *value, size_t value_length) |
request_header_fn callbacke, which is call from LwIP WSAPI http server More... | |
#define MAX_HTTP_REQUEST 1024 |
LwIP WSAPI C/C++ implementation.
This is C/C++ implementation of Lua's WSAPI or prospal related to WSGI 2.0, for LwIP stack, which is base on tcp callbacks. The interface is like Lua's WSAPI, but extend to context pointers, while C don't have coroutines, and LwIP could work on more systems, so context switching could not be good idea.
+-----—+ +-------------------------------—+ | |Thread X| | LwIP Thread | | | | | +----------------------------—+| | | | | |LwIP || | | | | |+----------------—+ +--—+ || | +----------—+ | | | || WSAPI HTTP Server <--> Eth <-----—> HTTP Client | | | | |+-------—^-----—+ +--—+ || | +----------—+ | | | +--------—|----------------—+| | |+---—+| | +--------—v---------—+ | | || Data <-----—> WSAPI HTTP Application | | | |+---—+| | +---------------------—+ | | +-----—+ +-------------------------------—+ | maximum of HTTP request without payload
#define METHOD_LENGTH 10 |
maximum method length (PROPPATCH) from WebDAV + \0
#define URI_LENGTH 64 |
maximum length of request uri
#define lwsapi_dbg _dbg |
#define lwsapi_error _dbg |
#define lwsapi_free | ( | arg | ) |
typedef IResponse::unique_ptr_t() application_fn(Environment &env) |
application_fn typedef, which is called in tcp_recv callback.
This is "WSGI" application handler, which gets reference to Environment structure. This must return IResponse::unique_ptr_t, which must implements generator method to return response content iterative if is needed.
typedef IHeader*() request_header_fn(const char *key, size_t key_length, const char *value, size_t value_length) |
This factory is used for parsing input headers.
request_header_fn is called when each header was detected in request. Application part of this http server must implement this function to decide which header is needed, and which not. All other headers will be ignored.
IResponse::unique_ptr_t application | ( | Environment & | env | ) |
Define of application functions.
Define of application functions.
env | request environment defined in lwsapi.h |
arg | pointer to pointer to internal application reqeust object. This pointer is argument of coroutine_fn funtcions. |
Return new ConstHeader.
Return new DynamicsHeader.
Response new NumberHeader.