summaryrefslogtreecommitdiffstats
path: root/crypto/http
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-11-30 16:44:59 +0100
committerDr. David von Oheimb <dev@ddvo.net>2021-12-03 12:25:52 +0100
commit17f5c1d9bab0127260ec212c55fc7193fea099a5 (patch)
treef4e2360b539d17cc5f4bd6cb85ab2894bdcca4e7 /crypto/http
parent1cafe4fc33c1dae7dd5024f600475fa96637b128 (diff)
OSSL_HTTP_REQ_CTX_nbio(): Fix parsing of responses with status code != 200
This way keep-alive is not (needlessly) cancelled on error. Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17171) (cherry picked from commit 38288f424faa0cf61bd705c497bb1a1657611da1)
Diffstat (limited to 'crypto/http')
-rw-r--r--crypto/http/http_client.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c
index f1e2b25a28..6a8149ba59 100644
--- a/crypto/http/http_client.c
+++ b/crypto/http/http_client.c
@@ -634,7 +634,7 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
/* fall through */
default:
rctx->state = OHS_ERROR;
- return 0;
+ goto next_line;
}
}
key = buf;
@@ -693,11 +693,6 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
if (*p != '\0') /* not end of headers */
goto next_line;
- if (rctx->expected_ct != NULL && !found_expected_ct) {
- ERR_raise_data(ERR_LIB_HTTP, HTTP_R_MISSING_CONTENT_TYPE,
- "expected=%s", rctx->expected_ct);
- return 0;
- }
if (rctx->keep_alive != 0 /* do not let server initiate keep_alive */
&& !found_keep_alive /* otherwise there is no change */) {
if (rctx->keep_alive == 2) {
@@ -708,6 +703,14 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
rctx->keep_alive = 0;
}
+ if (rctx->state == OHS_ERROR)
+ return 0;
+
+ if (rctx->expected_ct != NULL && !found_expected_ct) {
+ ERR_raise_data(ERR_LIB_HTTP, HTTP_R_MISSING_CONTENT_TYPE,
+ "expected=%s", rctx->expected_ct);
+ return 0;
+ }
if (rctx->state == OHS_REDIRECT) {
/* http status code indicated redirect but there was no Location */
ERR_raise(ERR_LIB_HTTP, HTTP_R_MISSING_REDIRECT_LOCATION);