1 
2 /*
3  * Copyright (C) NGINX, Inc.
4  */
5 
6 
7 #include <python/nxt_python.h>
8 
9 #if (NXT_HAVE_ASGI)
10 
11 #include <nxt_main.h>
12 #include <python/nxt_python_asgi_str.h>
13 
14 
15 PyObject  *nxt_py_1_0_str;
16 PyObject  *nxt_py_1_1_str;
17 PyObject  *nxt_py_2_0_str;
18 PyObject  *nxt_py_2_1_str;
19 PyObject  *nxt_py_3_0_str;
20 PyObject  *nxt_py_add_done_callback_str;
21 PyObject  *nxt_py_asgi_str;
22 PyObject  *nxt_py_bad_state_str;
23 PyObject  *nxt_py_body_str;
24 PyObject  *nxt_py_bytes_str;
25 PyObject  *nxt_py_client_str;
26 PyObject  *nxt_py_code_str;
27 PyObject  *nxt_py_done_str;
28 PyObject  *nxt_py_exception_str;
29 PyObject  *nxt_py_failed_to_send_body_str;
30 PyObject  *nxt_py_headers_str;
31 PyObject  *nxt_py_http_str;
32 PyObject  *nxt_py_http_disconnect_str;
33 PyObject  *nxt_py_http_request_str;
34 PyObject  *nxt_py_http_version_str;
35 PyObject  *nxt_py_https_str;
36 PyObject  *nxt_py_lifespan_str;
37 PyObject  *nxt_py_lifespan_shutdown_str;
38 PyObject  *nxt_py_lifespan_startup_str;
39 PyObject  *nxt_py_method_str;
40 PyObject  *nxt_py_message_str;
41 PyObject  *nxt_py_message_too_big_str;
42 PyObject  *nxt_py_more_body_str;
43 PyObject  *nxt_py_path_str;
44 PyObject  *nxt_py_query_string_str;
45 PyObject  *nxt_py_raw_path_str;
46 PyObject  *nxt_py_result_str;
47 PyObject  *nxt_py_root_path_str;
48 PyObject  *nxt_py_scheme_str;
49 PyObject  *nxt_py_server_str;
50 PyObject  *nxt_py_set_exception_str;
51 PyObject  *nxt_py_set_result_str;
52 PyObject  *nxt_py_spec_version_str;
53 PyObject  *nxt_py_status_str;
54 PyObject  *nxt_py_subprotocol_str;
55 PyObject  *nxt_py_subprotocols_str;
56 PyObject  *nxt_py_text_str;
57 PyObject  *nxt_py_type_str;
58 PyObject  *nxt_py_version_str;
59 PyObject  *nxt_py_websocket_str;
60 PyObject  *nxt_py_websocket_accept_str;
61 PyObject  *nxt_py_websocket_close_str;
62 PyObject  *nxt_py_websocket_connect_str;
63 PyObject  *nxt_py_websocket_disconnect_str;
64 PyObject  *nxt_py_websocket_receive_str;
65 PyObject  *nxt_py_websocket_send_str;
66 PyObject  *nxt_py_ws_str;
67 PyObject  *nxt_py_wss_str;
68 
69 static nxt_python_string_t nxt_py_asgi_strings[] = {
70     { nxt_string("1.0"), &nxt_py_1_0_str },
71     { nxt_string("1.1"), &nxt_py_1_1_str },
72     { nxt_string("2.0"), &nxt_py_2_0_str },
73     { nxt_string("2.1"), &nxt_py_2_1_str },
74     { nxt_string("3.0"), &nxt_py_3_0_str },
75     { nxt_string("add_done_callback"), &nxt_py_add_done_callback_str },
76     { nxt_string("asgi"), &nxt_py_asgi_str },
77     { nxt_string("bad state"), &nxt_py_bad_state_str },
78     { nxt_string("body"), &nxt_py_body_str },
79     { nxt_string("bytes"), &nxt_py_bytes_str },
80     { nxt_string("client"), &nxt_py_client_str },
81     { nxt_string("code"), &nxt_py_code_str },
82     { nxt_string("done"), &nxt_py_done_str },
83     { nxt_string("exception"), &nxt_py_exception_str },
84     { nxt_string("failed to send body"), &nxt_py_failed_to_send_body_str },
85     { nxt_string("headers"), &nxt_py_headers_str },
86     { nxt_string("http"), &nxt_py_http_str },
87     { nxt_string("http.disconnect"), &nxt_py_http_disconnect_str },
88     { nxt_string("http.request"), &nxt_py_http_request_str },
89     { nxt_string("http_version"), &nxt_py_http_version_str },
90     { nxt_string("https"), &nxt_py_https_str },
91     { nxt_string("lifespan"), &nxt_py_lifespan_str },
92     { nxt_string("lifespan.shutdown"), &nxt_py_lifespan_shutdown_str },
93     { nxt_string("lifespan.startup"), &nxt_py_lifespan_startup_str },
94     { nxt_string("message"), &nxt_py_message_str },
95     { nxt_string("message too big"), &nxt_py_message_too_big_str },
96     { nxt_string("method"), &nxt_py_method_str },
97     { nxt_string("more_body"), &nxt_py_more_body_str },
98     { nxt_string("path"), &nxt_py_path_str },
99     { nxt_string("query_string"), &nxt_py_query_string_str },
100     { nxt_string("raw_path"), &nxt_py_raw_path_str },
101     { nxt_string("result"), &nxt_py_result_str },
102     { nxt_string("root_path"), &nxt_py_root_path_str }, // not used
103     { nxt_string("scheme"), &nxt_py_scheme_str },
104     { nxt_string("server"), &nxt_py_server_str },
105     { nxt_string("set_exception"), &nxt_py_set_exception_str },
106     { nxt_string("set_result"), &nxt_py_set_result_str },
107     { nxt_string("spec_version"), &nxt_py_spec_version_str },
108     { nxt_string("status"), &nxt_py_status_str },
109     { nxt_string("subprotocol"), &nxt_py_subprotocol_str },
110     { nxt_string("subprotocols"), &nxt_py_subprotocols_str },
111     { nxt_string("text"), &nxt_py_text_str },
112     { nxt_string("type"), &nxt_py_type_str },
113     { nxt_string("version"), &nxt_py_version_str },
114     { nxt_string("websocket"), &nxt_py_websocket_str },
115     { nxt_string("websocket.accept"), &nxt_py_websocket_accept_str },
116     { nxt_string("websocket.close"), &nxt_py_websocket_close_str },
117     { nxt_string("websocket.connect"), &nxt_py_websocket_connect_str },
118     { nxt_string("websocket.disconnect"), &nxt_py_websocket_disconnect_str },
119     { nxt_string("websocket.receive"), &nxt_py_websocket_receive_str },
120     { nxt_string("websocket.send"), &nxt_py_websocket_send_str },
121     { nxt_string("ws"), &nxt_py_ws_str },
122     { nxt_string("wss"), &nxt_py_wss_str },
123     { nxt_null_string, NULL },
124 };
125 
126 
127 int
nxt_py_asgi_str_init(void)128 nxt_py_asgi_str_init(void)
129 {
130     return nxt_python_init_strings(nxt_py_asgi_strings);
131 }
132 
133 
134 void
nxt_py_asgi_str_done(void)135 nxt_py_asgi_str_done(void)
136 {
137     nxt_python_done_strings(nxt_py_asgi_strings);
138 }
139 
140 
141 #endif /* NXT_HAVE_ASGI */
142