summaryrefslogtreecommitdiffstats
path: root/crypto/http/http_client.c
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-05-03 16:33:10 +0200
committerDr. David von Oheimb <dev@ddvo.net>2021-05-14 19:24:42 +0200
commit829902879eb7ba1260a9444f6b6b91d84ca61037 (patch)
tree3bfa9571c2115585d905421a45e7a9053ea84c66 /crypto/http/http_client.c
parent22fe2b129922bc9322c41ce8beff1551c078c838 (diff)
HTTP client API: Generalize to arbitrary request and response contents
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15053)
Diffstat (limited to 'crypto/http/http_client.c')
-rw-r--r--crypto/http/http_client.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c
index ee97f64ef6..077159cab6 100644
--- a/crypto/http/http_client.c
+++ b/crypto/http/http_client.c
@@ -796,6 +796,7 @@ static BIO *HTTP_new_bio(const char *server /* optionally includes ":port" */,
}
#endif /* OPENSSL_NO_SOCK */
+/* Exchange request and response via HTTP on (non-)blocking BIO */
BIO *OSSL_HTTP_REQ_CTX_exchange(OSSL_HTTP_REQ_CTX *rctx)
{
int rv;
@@ -856,6 +857,10 @@ OSSL_HTTP_REQ_CTX *OSSL_HTTP_open(const char *server, const char *port,
if (bio != NULL) {
cbio = bio;
+ if (proxy != NULL || no_proxy != NULL) {
+ ERR_raise(ERR_LIB_HTTP, ERR_R_PASSED_INVALID_ARGUMENT);
+ return NULL;
+ }
} else {
#ifndef OPENSSL_NO_SOCK
char *proxy_host = NULL, *proxy_port = NULL;
@@ -1064,7 +1069,7 @@ BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy,
NULL /* content_type */,
NULL /* req_mem */,
expected_ct, expect_asn1,
- -1 /* use same max time */,
+ -1 /* use same max time (timeout) */,
0 /* no keep_alive */))
OSSL_HTTP_REQ_CTX_free(rctx);
else
@@ -1100,6 +1105,7 @@ BIO *OSSL_HTTP_get(const char *url, const char *proxy, const char *no_proxy,
return resp;
}
+/* Exchange request and response over a connection managed via |prctx| */
BIO *OSSL_HTTP_transfer(OSSL_HTTP_REQ_CTX **prctx,
const char *server, const char *port,
const char *path, int use_ssl,
@@ -1122,11 +1128,14 @@ BIO *OSSL_HTTP_transfer(OSSL_HTTP_REQ_CTX **prctx,
}
if (rctx != NULL) {
if (OSSL_HTTP_set_request(rctx, path, headers, content_type, req,
- expected_ct, expect_asn1, timeout, keep_alive))
+ expected_ct, expect_asn1,
+ timeout, keep_alive))
resp = OSSL_HTTP_exchange(rctx, NULL);
if (resp == NULL || !OSSL_HTTP_is_alive(rctx)) {
- if (!OSSL_HTTP_close(rctx, resp != NULL))
+ if (!OSSL_HTTP_close(rctx, resp != NULL)) {
+ BIO_free(resp);
resp = NULL;
+ }
rctx = NULL;
}
}