summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_python_wsgi.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-08-17 21:47:19 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-08-17 21:47:19 +0300
commit949548da293fa30ef200d07c3e4ff108174404b7 (patch)
tree8f03eaad277ec558f9ce2f223db350d134532e4b /src/nxt_python_wsgi.c
parent5ef8e0ee8933e914b1847168255b53f07c3727b3 (diff)
downloadunit-949548da293fa30ef200d07c3e4ff108174404b7.tar.gz
unit-949548da293fa30ef200d07c3e4ff108174404b7.tar.bz2
The new module configuration interface.
Configuration and building example: ./configure ./configure python ./configure php ./configure go make all or ./configure make nginext ./configure python make python ./configure php make php ./configure go make go Modules configuration options and building examples: ./configure python --module=python2 --config=python2.7-config make python2 ./configure php --module=php7 --config=php7.0-config --lib-path=/usr/local/php7.0 make php7 ./configure go --go=go1.6 --go-path=${HOME}/go1.6 make go1.6
Diffstat (limited to 'src/nxt_python_wsgi.c')
-rw-r--r--src/nxt_python_wsgi.c107
1 files changed, 4 insertions, 103 deletions
diff --git a/src/nxt_python_wsgi.c b/src/nxt_python_wsgi.c
index f1bd170f..f5c3ebae 100644
--- a/src/nxt_python_wsgi.c
+++ b/src/nxt_python_wsgi.c
@@ -61,9 +61,6 @@ typedef struct nxt_python_run_ctx_s nxt_python_run_ctx_t;
static nxt_int_t nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf);
-static nxt_int_t nxt_python_prepare_msg(nxt_task_t *task,
- nxt_app_request_t *r, nxt_app_wmsg_t *msg);
-
static nxt_int_t nxt_python_run(nxt_task_t *task,
nxt_app_rmsg_t *rmsg, nxt_app_wmsg_t *msg);
@@ -93,13 +90,12 @@ nxt_inline nxt_int_t nxt_python_write(nxt_python_run_ctx_t *ctx,
nxt_inline nxt_int_t nxt_python_write_py_str(nxt_python_run_ctx_t *ctx,
PyObject *str, nxt_bool_t flush, nxt_bool_t last);
-extern nxt_int_t nxt_python_wsgi_init(nxt_thread_t *thr, nxt_runtime_t *rt);
-
-nxt_application_module_t nxt_python_module = {
+NXT_EXPORT nxt_application_module_t nxt_app_module = {
+ nxt_string("python"),
+ nxt_string(PY_VERSION),
nxt_python_init,
- nxt_python_prepare_msg,
- nxt_python_run
+ nxt_python_run,
};
@@ -177,23 +173,6 @@ static PyObject *nxt_py_environ_ptyp;
static nxt_python_run_ctx_t *nxt_python_run_ctx;
-nxt_int_t
-nxt_python_wsgi_init(nxt_thread_t *thr, nxt_runtime_t *rt)
-{
- nxt_app_modules[NXT_APP_PYTHON] = &nxt_python_module;
-
-#if PY_MAJOR_VERSION == 2
- nxt_app_modules[NXT_APP_PYTHON2] = &nxt_python_module;
-#endif
-
-#if PY_MAJOR_VERSION == 3
- nxt_app_modules[NXT_APP_PYTHON3] = &nxt_python_module;
-#endif
-
- return NXT_OK;
-}
-
-
static nxt_int_t
nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
{
@@ -320,84 +299,6 @@ fail:
static nxt_int_t
-nxt_python_prepare_msg(nxt_task_t *task, nxt_app_request_t *r,
- nxt_app_wmsg_t *wmsg)
-{
- nxt_int_t rc;
- nxt_buf_t *b;
- nxt_http_field_t *field;
- nxt_app_request_header_t *h;
-
- static const nxt_str_t prefix = nxt_string("HTTP_");
- static const nxt_str_t eof = nxt_null_string;
-
- h = &r->header;
-
-#define RC(S) \
- do { \
- rc = (S); \
- if (nxt_slow_path(rc != NXT_OK)) { \
- goto fail; \
- } \
- } while(0)
-
-#define NXT_WRITE(N) \
- RC(nxt_app_msg_write_str(task, wmsg, N))
-
- /* TODO error handle, async mmap buffer assignment */
-
- NXT_WRITE(&h->method);
- NXT_WRITE(&h->target);
- if (h->path.start == h->target.start) {
- NXT_WRITE(&eof);
- } else {
- NXT_WRITE(&h->path);
- }
-
- if (h->query.start != NULL) {
- RC(nxt_app_msg_write_size(task, wmsg,
- h->query.start - h->target.start + 1));
- } else {
- RC(nxt_app_msg_write_size(task, wmsg, 0));
- }
-
- NXT_WRITE(&h->version);
-
- NXT_WRITE(&r->remote);
-
- NXT_WRITE(&h->host);
- NXT_WRITE(&h->content_type);
- NXT_WRITE(&h->content_length);
-
- nxt_list_each(field, h->fields) {
- RC(nxt_app_msg_write_prefixed_upcase(task, wmsg,
- &prefix, &field->name));
- NXT_WRITE(&field->value);
-
- } nxt_list_loop;
-
- /* end-of-headers mark */
- NXT_WRITE(&eof);
-
- RC(nxt_app_msg_write_size(task, wmsg, r->body.preread_size));
-
- for(b = r->body.buf; b != NULL; b = b->next) {
- RC(nxt_app_msg_write_raw(task, wmsg, b->mem.pos,
- nxt_buf_mem_used_size(&b->mem)));
- }
-
-#undef NXT_WRITE
-#undef RC
-
- return NXT_OK;
-
-fail:
-
- return NXT_ERROR;
-}
-
-
-static nxt_int_t
nxt_python_run(nxt_task_t *task, nxt_app_rmsg_t *rmsg, nxt_app_wmsg_t *wmsg)
{
u_char *buf;