From 1455a6fa77fb47039a39d232d1ed6e6b0f317b05 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 27 May 2020 00:27:15 +0300 Subject: [PATCH] lib-oauth2: Don't fail if oauth response payload is NULL oauth2_parse_json() is happy with with empty payload (Content-Length: 0), so it should be happy also when payload is NULL (Content-Length is missing). --- src/lib-oauth2/oauth2-request.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib-oauth2/oauth2-request.c b/src/lib-oauth2/oauth2-request.c index 15bce9d7d7..4f1a7f7358 100644 --- a/src/lib-oauth2/oauth2-request.c +++ b/src/lib-oauth2/oauth2-request.c @@ -77,17 +77,15 @@ static void oauth2_request_response(const struct http_response *response, struct oauth2_request *req) { - if (response->payload == NULL) { - struct oauth2_request_result res; - i_zero(&res); - res.error = http_response_get_message(response); - oauth2_request_callback(req, &res); - return; + if (response->payload != NULL) { + req->is = response->payload; + i_stream_ref(req->is); + } else { + req->is = i_stream_create_from_data("", 0); } + req->response_status = response->status; p_array_init(&req->fields, req->pool, 1); - req->is = response->payload; - i_stream_ref(req->is); req->parser = json_parser_init(req->is); req->json_parsed_cb = oauth2_request_continue; req->io = io_add_istream(req->is, oauth2_parse_json, req); -- 2.47.3