1 2 /* 3 * Copyright (C) NGINX, Inc. 4 */ 5 6 #ifndef _NXT_PYTHON_ASGI_H_INCLUDED_ 7 #define _NXT_PYTHON_ASGI_H_INCLUDED_ 8 9 10 typedef PyObject * (*nxt_py_asgi_enum_header_cb)(void *ctx, int i, 11 PyObject *name, PyObject *val); 12 13 typedef struct { 14 uint32_t fields_count; 15 uint32_t fields_size; 16 } nxt_py_asgi_calc_size_ctx_t; 17 18 typedef struct { 19 nxt_unit_request_info_t *req; 20 uint64_t content_length; 21 } nxt_py_asgi_add_field_ctx_t; 22 23 PyObject *nxt_py_asgi_enum_headers(PyObject *headers, 24 nxt_py_asgi_enum_header_cb cb, void *data); 25 26 PyObject *nxt_py_asgi_calc_size(void *data, int i, PyObject *n, PyObject *v); 27 PyObject *nxt_py_asgi_add_field(void *data, int i, PyObject *n, PyObject *v); 28 29 PyObject *nxt_py_asgi_set_result_soon(nxt_unit_request_info_t *req, 30 PyObject *future, PyObject *result); 31 PyObject *nxt_py_asgi_new_msg(nxt_unit_request_info_t *req, PyObject *type); 32 PyObject *nxt_py_asgi_new_scope(nxt_unit_request_info_t *req, PyObject *type, 33 PyObject *spec_version); 34 35 void nxt_py_asgi_dealloc(PyObject *self); 36 PyObject *nxt_py_asgi_await(PyObject *self); 37 PyObject *nxt_py_asgi_iter(PyObject *self); 38 PyObject *nxt_py_asgi_next(PyObject *self); 39 40 nxt_int_t nxt_py_asgi_http_init(nxt_task_t *task); 41 PyObject *nxt_py_asgi_http_create(nxt_unit_request_info_t *req); 42 void nxt_py_asgi_http_data_handler(nxt_unit_request_info_t *req); 43 int nxt_py_asgi_http_drain(nxt_queue_link_t *lnk); 44 45 nxt_int_t nxt_py_asgi_websocket_init(nxt_task_t *task); 46 PyObject *nxt_py_asgi_websocket_create(nxt_unit_request_info_t *req); 47 void nxt_py_asgi_websocket_handler(nxt_unit_websocket_frame_t *ws); 48 void nxt_py_asgi_websocket_close_handler(nxt_unit_request_info_t *req); 49 50 nxt_int_t nxt_py_asgi_lifespan_startup(nxt_task_t *task); 51 nxt_int_t nxt_py_asgi_lifespan_shutdown(void); 52 53 extern PyObject *nxt_py_loop_run_until_complete; 54 extern PyObject *nxt_py_loop_create_future; 55 extern PyObject *nxt_py_loop_create_task; 56 57 extern nxt_queue_t nxt_py_asgi_drain_queue; 58 59 60 #endif /* _NXT_PYTHON_ASGI_H_INCLUDED_ */ 61