11624Smax.romanov@nginx.com 21624Smax.romanov@nginx.com /* 31624Smax.romanov@nginx.com * Copyright (C) NGINX, Inc. 41624Smax.romanov@nginx.com */ 51624Smax.romanov@nginx.com 61624Smax.romanov@nginx.com #ifndef _NXT_PYTHON_ASGI_H_INCLUDED_ 71624Smax.romanov@nginx.com #define _NXT_PYTHON_ASGI_H_INCLUDED_ 81624Smax.romanov@nginx.com 91624Smax.romanov@nginx.com 101624Smax.romanov@nginx.com typedef PyObject * (*nxt_py_asgi_enum_header_cb)(void *ctx, int i, 111624Smax.romanov@nginx.com PyObject *name, PyObject *val); 121624Smax.romanov@nginx.com 131681Smax.romanov@nginx.com void nxt_py_asgi_drain_wait(nxt_unit_request_info_t *req, 141681Smax.romanov@nginx.com nxt_queue_link_t *link); 151681Smax.romanov@nginx.com 161624Smax.romanov@nginx.com typedef struct { 171624Smax.romanov@nginx.com uint32_t fields_count; 181624Smax.romanov@nginx.com uint32_t fields_size; 191624Smax.romanov@nginx.com } nxt_py_asgi_calc_size_ctx_t; 201624Smax.romanov@nginx.com 211624Smax.romanov@nginx.com typedef struct { 221624Smax.romanov@nginx.com nxt_unit_request_info_t *req; 231624Smax.romanov@nginx.com uint64_t content_length; 241624Smax.romanov@nginx.com } nxt_py_asgi_add_field_ctx_t; 251624Smax.romanov@nginx.com 261681Smax.romanov@nginx.com typedef struct { 271681Smax.romanov@nginx.com nxt_queue_t drain_queue; 281681Smax.romanov@nginx.com PyObject *loop_run_until_complete; 291681Smax.romanov@nginx.com PyObject *loop_create_future; 301681Smax.romanov@nginx.com PyObject *loop_create_task; 311681Smax.romanov@nginx.com PyObject *loop_call_soon; 321681Smax.romanov@nginx.com PyObject *loop_add_reader; 331681Smax.romanov@nginx.com PyObject *loop_remove_reader; 341681Smax.romanov@nginx.com PyObject *quit_future; 351681Smax.romanov@nginx.com PyObject *quit_future_set_result; 36*1872So.canty@f5.com PyObject **target_lifespans; 371681Smax.romanov@nginx.com } nxt_py_asgi_ctx_data_t; 381681Smax.romanov@nginx.com 391624Smax.romanov@nginx.com PyObject *nxt_py_asgi_enum_headers(PyObject *headers, 401624Smax.romanov@nginx.com nxt_py_asgi_enum_header_cb cb, void *data); 411624Smax.romanov@nginx.com 421624Smax.romanov@nginx.com PyObject *nxt_py_asgi_calc_size(void *data, int i, PyObject *n, PyObject *v); 431624Smax.romanov@nginx.com PyObject *nxt_py_asgi_add_field(void *data, int i, PyObject *n, PyObject *v); 441624Smax.romanov@nginx.com 451624Smax.romanov@nginx.com PyObject *nxt_py_asgi_set_result_soon(nxt_unit_request_info_t *req, 461681Smax.romanov@nginx.com nxt_py_asgi_ctx_data_t *ctx_data, PyObject *future, PyObject *result); 471624Smax.romanov@nginx.com PyObject *nxt_py_asgi_new_msg(nxt_unit_request_info_t *req, PyObject *type); 481624Smax.romanov@nginx.com PyObject *nxt_py_asgi_new_scope(nxt_unit_request_info_t *req, PyObject *type, 491624Smax.romanov@nginx.com PyObject *spec_version); 501624Smax.romanov@nginx.com 511624Smax.romanov@nginx.com void nxt_py_asgi_dealloc(PyObject *self); 521624Smax.romanov@nginx.com PyObject *nxt_py_asgi_await(PyObject *self); 531624Smax.romanov@nginx.com PyObject *nxt_py_asgi_iter(PyObject *self); 541624Smax.romanov@nginx.com PyObject *nxt_py_asgi_next(PyObject *self); 551624Smax.romanov@nginx.com 561681Smax.romanov@nginx.com int nxt_py_asgi_http_init(void); 571624Smax.romanov@nginx.com PyObject *nxt_py_asgi_http_create(nxt_unit_request_info_t *req); 581624Smax.romanov@nginx.com void nxt_py_asgi_http_data_handler(nxt_unit_request_info_t *req); 591624Smax.romanov@nginx.com int nxt_py_asgi_http_drain(nxt_queue_link_t *lnk); 601715Smax.romanov@nginx.com void nxt_py_asgi_http_close_handler(nxt_unit_request_info_t *req); 611624Smax.romanov@nginx.com 621681Smax.romanov@nginx.com int nxt_py_asgi_websocket_init(void); 631624Smax.romanov@nginx.com PyObject *nxt_py_asgi_websocket_create(nxt_unit_request_info_t *req); 641624Smax.romanov@nginx.com void nxt_py_asgi_websocket_handler(nxt_unit_websocket_frame_t *ws); 651624Smax.romanov@nginx.com void nxt_py_asgi_websocket_close_handler(nxt_unit_request_info_t *req); 661624Smax.romanov@nginx.com 671681Smax.romanov@nginx.com int nxt_py_asgi_lifespan_startup(nxt_py_asgi_ctx_data_t *ctx_data); 681681Smax.romanov@nginx.com int nxt_py_asgi_lifespan_shutdown(nxt_unit_ctx_t *ctx); 691624Smax.romanov@nginx.com 701624Smax.romanov@nginx.com 711624Smax.romanov@nginx.com #endif /* _NXT_PYTHON_ASGI_H_INCLUDED_ */ 72