mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 04:29:02 -04:00
Python: add a protocol member to kore.httprequest
This returns a string depending on the protocol used (https / http) for the HTTP request.
This commit is contained in:
parent
a3800fa57e
commit
ff19ce7652
@ -780,6 +780,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_protocol(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 *);
|
||||
@ -790,6 +791,7 @@ static PyGetSetDef pyhttp_request_getset[] = {
|
||||
GETTER("body", pyhttp_get_body),
|
||||
GETTER("agent", pyhttp_get_agent),
|
||||
GETTER("method", pyhttp_get_method),
|
||||
GETTER("protocol", pyhttp_get_protocol),
|
||||
GETTER("body_path", pyhttp_get_body_path),
|
||||
GETTER("body_digest", pyhttp_get_body_digest),
|
||||
GETTER("connection", pyhttp_get_connection),
|
||||
|
16
src/python.c
16
src/python.c
@ -5171,6 +5171,22 @@ pyhttp_get_method(struct pyhttp_request *pyreq, void *closure)
|
||||
return (PyLong_FromUnsignedLong(pyreq->req->method));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pyhttp_get_protocol(struct pyhttp_request *pyreq, void *closure)
|
||||
{
|
||||
struct connection *c;
|
||||
const char *proto;
|
||||
|
||||
c = pyreq->req->owner;
|
||||
|
||||
if (c->owner->server->tls)
|
||||
proto = "https";
|
||||
else
|
||||
proto = "http";
|
||||
|
||||
return (PyUnicode_FromString(proto));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
pyhttp_get_body_path(struct pyhttp_request *pyreq, void *closure)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user