kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 994f428a8df61513b9f87be86625b471483d76df
parent 6bd3d92fe2d68b209ae416ca5ed11839fa380397
Author: Joris Vink <joris@coders.se>
Date:   Wed, 24 Apr 2019 21:09:24 +0200

add cabundle keyword to kore.httpclient()

Diffstat:
include/kore/python_methods.h | 3++-
src/python.c | 19++++++++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/include/kore/python_methods.h b/include/kore/python_methods.h @@ -652,8 +652,9 @@ static PyTypeObject pyhttp_file_type = { struct pyhttp_client { PyObject_HEAD char *url; - char *tlscert; char *tlskey; + char *tlscert; + char *cabundle; int tlsverify; }; diff --git a/src/python.c b/src/python.c @@ -3774,9 +3774,11 @@ python_kore_httpclient(PyObject *self, PyObject *args, PyObject *kwargs) if (client == NULL) return (NULL); - client->tlsverify = 1; client->tlskey = NULL; client->tlscert = NULL; + client->cabundle = NULL; + + client->tlsverify = 1; client->url = kore_strdup(url); if (kwargs != NULL) { @@ -3798,6 +3800,15 @@ python_kore_httpclient(PyObject *self, PyObject *args, PyObject *kwargs) client->tlskey = kore_strdup(v); } + if ((obj = PyDict_GetItemString(kwargs, "cabundle")) != NULL) { + if ((v = PyUnicode_AsUTF8(obj)) == NULL) { + Py_DECREF((PyObject *)client); + return (NULL); + } + + client->cabundle = kore_strdup(v); + } + if ((obj = PyDict_GetItemString(kwargs, "tlsverify")) != NULL) { if (obj == Py_True) { client->tlsverify = 1; @@ -3829,6 +3840,7 @@ pyhttp_client_dealloc(struct pyhttp_client *client) kore_free(client->url); kore_free(client->tlskey); kore_free(client->tlscert); + kore_free(client->cabundle); PyObject_Del((PyObject *)client); } @@ -3971,6 +3983,11 @@ pyhttp_client_request(struct pyhttp_client *client, int m, PyObject *kwargs) } } + if (client->cabundle != NULL) { + curl_easy_setopt(op->curl.handle, CURLOPT_CAINFO, + client->cabundle); + } + if (headers != NULL) { idx = 0; while (PyDict_Next(headers, &idx, &key, &item)) {