kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit c6ca68f3f258bd76460f703b9ad7165138c6d434
parent 2f670ce777481ed53051d70dd4900fcd4c150215
Author: Joris Vink <joris@coders.se>
Date:   Wed, 22 Feb 2017 17:52:57 +0100

export http_body_path via python

Diffstat:
includes/python_methods.h | 2++
src/python.c | 15+++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/includes/python_methods.h b/includes/python_methods.h @@ -127,6 +127,7 @@ static PyObject *pyhttp_get_path(struct pyhttp_request *, void *); static PyObject *pyhttp_get_body(struct pyhttp_request *, void *); static PyObject *pyhttp_get_agent(struct pyhttp_request *, void *); static PyObject *pyhttp_get_method(struct pyhttp_request *, void *); +static PyObject *pyhttp_get_body_path(struct pyhttp_request *, void *); static PyObject *pyhttp_get_connection(struct pyhttp_request *, void *); static PyGetSetDef pyhttp_request_getset[] = { @@ -135,6 +136,7 @@ static PyGetSetDef pyhttp_request_getset[] = { GETTER("body", pyhttp_get_body), GETTER("agent", pyhttp_get_agent), GETTER("method", pyhttp_get_method), + GETTER("body_path", pyhttp_get_body_path), GETTER("connection", pyhttp_get_connection), GETTER(NULL, NULL) }; diff --git a/src/python.c b/src/python.c @@ -1072,6 +1072,21 @@ pyhttp_get_method(struct pyhttp_request *pyreq, void *closure) } static PyObject * +pyhttp_get_body_path(struct pyhttp_request *pyreq, void *closure) +{ + PyObject *path; + + if (pyreq->req->http_body_path == NULL) { + Py_RETURN_NONE; + } + + if ((path = PyUnicode_FromString(pyreq->req->http_body_path)) == NULL) + return (PyErr_NoMemory()); + + return (path); +} + +static PyObject * pyhttp_get_connection(struct pyhttp_request *pyreq, void *closure) { PyObject *pyc;