diff options
author | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2021-05-05 00:09:43 +0200 |
---|---|---|
committer | Dr. David von Oheimb <dev@ddvo.net> | 2021-05-12 15:11:51 +0200 |
commit | 8f965908a53b4f0c5a735739e8a273a3a33a976e (patch) | |
tree | 9efe89d630473e84898a5a00f2898f9b0f7fbdbd /test | |
parent | 4329f361ce75973ceca9d440e8430580ee515070 (diff) |
HTTP client: Minimal changes that include the improved API
This is a minimal version of pull request #15053 including all the
proposed improvements to the HTTP client API and its documentation
but only those code adaptations strictly needed for it.
The proposed new features include
* support for persistent connections (keep-alive),
* generalization to arbitrary request and response types, and
* support for streaming BIOs for request and response data.
The related API changes include:
* Split the monolithic OSSL_HTTP_transfer() into OSSL_HTTP_open(),
OSSL_HTTP_set_request(), a lean OSSL_HTTP_transfer(), and OSSL_HTTP_close().
* Split the timeout functionality accordingly and improve default behavior.
* Extract part of OSSL_HTTP_REQ_CTX_new() to OSSL_HTTP_REQ_CTX_set_expected().
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15147)
Diffstat (limited to 'test')
-rw-r--r-- | test/cmp_ctx_test.c | 7 | ||||
-rw-r--r-- | test/http_test.c | 38 |
2 files changed, 23 insertions, 22 deletions
diff --git a/test/cmp_ctx_test.c b/test/cmp_ctx_test.c index 2ca2c26dd5..e25aa9ab43 100644 --- a/test/cmp_ctx_test.c +++ b/test/cmp_ctx_test.c @@ -717,9 +717,8 @@ void cleanup_tests(void) return; } -DEFINE_SET_GET_ARG_FN(set, get, option, 16, int) -/* option == OSSL_CMP_OPT_IGNORE_KEYUSAGE */ -DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, option_16, int, -1, IS_0, \ +DEFINE_SET_GET_ARG_FN(set, get, option, 35, int) /* OPT_IGNORE_KEYUSAGE */ +DEFINE_SET_GET_BASE_TEST(OSSL_CMP_CTX, set, get, 0, option_35, int, -1, IS_0, \ 1 /* true */, DROP) DEFINE_SET_CB_TEST(log_cb) @@ -792,7 +791,7 @@ int setup_tests(void) ADD_TEST(test_CTX_reinit); /* various CMP options: */ - ADD_TEST(test_CTX_set_get_option_16); + ADD_TEST(test_CTX_set_get_option_35); /* CMP-specific callback for logging and outputting the error queue: */ ADD_TEST(test_CTX_set_get_log_cb); /* diff --git a/test/http_test.c b/test/http_test.c index 0a3389c15f..e4209a37c0 100644 --- a/test/http_test.c +++ b/test/http_test.c @@ -99,36 +99,38 @@ static int test_http_x509(int do_get) X509 *rcert = NULL; BIO *wbio = BIO_new(BIO_s_mem()); BIO *rbio = BIO_new(BIO_s_mem()); + BIO *rsp, *req = ASN1_item_i2d_mem_bio(x509_it, (ASN1_VALUE *)x509); STACK_OF(CONF_VALUE) *headers = NULL; + const char content_type[] = "application/x-x509-ca-cert"; int res = 0; - if (wbio == NULL || rbio == NULL) + if (wbio == NULL || rbio == NULL || req == NULL) goto err; BIO_set_callback_ex(wbio, http_bio_cb_ex); BIO_set_callback_arg(wbio, (char *)rbio); rpath = RPATH; - rcert = (X509 *) - (do_get ? - OSSL_HTTP_get_asn1("http://"SERVER":"PORT"/"RPATH, - NULL /* proxy */, NULL /* no_proxy */, - wbio, rbio, NULL /* bio_update_fn */, NULL, - headers, 0 /* maxline */, - 0 /* max_resp_len */, 0 /* timeout */, - "application/x-x509-ca-cert", x509_it) - : - OSSL_HTTP_post_asn1(SERVER, PORT, RPATH, 0 /* use_ssl */, - NULL /* proxy */, NULL /* no_proxy */, - wbio, rbio, NULL /* bio_update_fn */, NULL, - headers, "application/x-x509-ca-cert", - (ASN1_VALUE *)x509, x509_it, 0 /* maxline */, - 0 /* max_resp_len */, 0 /* timeout */, - "application/x-x509-ca-cert", x509_it) - ); + rsp = do_get ? + OSSL_HTTP_get("http://"SERVER":"PORT"/"RPATH, + NULL /* proxy */, NULL /* no_proxy */, + wbio, rbio, NULL /* bio_fn */, NULL /* arg */, + 0 /* buf_size */, headers, content_type, + 1 /* expect_asn1 */, + HTTP_DEFAULT_MAX_RESP_LEN, 0 /* timeout */) + : OSSL_HTTP_transfer(NULL, NULL /* host */, NULL /* port */, RPATH, + 0 /* use_ssl */,NULL /* proxy */, NULL /* no_pr */, + wbio, rbio, NULL /* bio_fn */, NULL /* arg */, + 0 /* buf_size */, headers, content_type, + req, content_type, 1 /* expect_asn1 */, + HTTP_DEFAULT_MAX_RESP_LEN, 0 /* timeout */, + 0 /* keep_alive */); + rcert = d2i_X509_bio(rsp, NULL); + BIO_free(rsp); res = TEST_ptr(rcert) && TEST_int_eq(X509_cmp(x509, rcert), 0); err: X509_free(rcert); + BIO_free(req); BIO_free(wbio); BIO_free(rbio); sk_CONF_VALUE_pop_free(headers, X509V3_conf_free); |