diff --git a/include/kore/python_methods.h b/include/kore/python_methods.h index 72112d0..ff44d96 100644 --- a/include/kore/python_methods.h +++ b/include/kore/python_methods.h @@ -782,6 +782,7 @@ 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 PyObject *pyhttp_get_body_digest(struct pyhttp_request *, void *); static PyGetSetDef pyhttp_request_getset[] = { GETTER("host", pyhttp_get_host), @@ -790,6 +791,7 @@ static PyGetSetDef pyhttp_request_getset[] = { GETTER("agent", pyhttp_get_agent), GETTER("method", pyhttp_get_method), GETTER("body_path", pyhttp_get_body_path), + GETTER("body_digest", pyhttp_get_body_digest), GETTER("connection", pyhttp_get_connection), GETTER(NULL, NULL) }; diff --git a/src/python.c b/src/python.c index 5a3259d..b38bf66 100644 --- a/src/python.c +++ b/src/python.c @@ -5109,42 +5109,34 @@ pyhttp_get_body(struct pyhttp_request *pyreq, void *closure) static PyObject * pyhttp_get_agent(struct pyhttp_request *pyreq, void *closure) { - PyObject *agent; - - if (pyreq->req->agent == NULL) { - Py_RETURN_NONE; - } - - if ((agent = PyUnicode_FromString(pyreq->req->path)) == NULL) - return (PyErr_NoMemory()); - - return (agent); + return (PyUnicode_FromString(pyreq->req->path)); } static PyObject * pyhttp_get_method(struct pyhttp_request *pyreq, void *closure) { - PyObject *method; - - if ((method = PyLong_FromUnsignedLong(pyreq->req->method)) == NULL) - return (PyErr_NoMemory()); - - return (method); + return (PyLong_FromUnsignedLong(pyreq->req->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 (PyUnicode_FromString(pyreq->req->http_body_path)); +} - return (path); +static PyObject * +pyhttp_get_body_digest(struct pyhttp_request *pyreq, void *closure) +{ + PyObject *digest; + + digest = PyBytes_FromStringAndSize((char *)pyreq->req->http_body_digest, + sizeof(pyreq->req->http_body_digest)); + + return (digest); } static PyObject *