diff --git a/includes/python_methods.h b/includes/python_methods.h index 9dbfba9..47f127c 100644 --- 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 index 39a355e..80e85d3 100644 --- a/src/python.c +++ b/src/python.c @@ -1071,6 +1071,21 @@ pyhttp_get_method(struct pyhttp_request *pyreq, void *closure) return (method); } +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) {