From 6692b8d5ffb2da3cd727a66c479d91a0218dba4e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 18 Feb 2015 14:07:14 +0100 Subject: [PATCH] http_client: returns 404 if no destination URI is given --- src/filter_http_client.cpp | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/filter_http_client.cpp b/src/filter_http_client.cpp index b8c2015..e3d6116 100644 --- a/src/filter_http_client.cpp +++ b/src/filter_http_client.cpp @@ -117,31 +117,37 @@ void yf::HTTPClient::Rep::proxy(mp::Package &package) else uri = hreq->path; - if (bind_host) { std::string host = package.origin().get_bind_address(); uri.append(" "); uri.append(host); } - Z_HTTP_Response *http_response = 0; - if (uri.length()) - http_response = - yaz_url_exec(yaz_url, uri.c_str(), hreq->method, - hreq->headers, hreq->content_buf, - hreq->content_len); - if (http_response) + if (!uri.length()) { - res_gdu = o.create_HTTP_Response(package.session(), hreq, 200); - z_HTTP_header_remove(&http_response->headers, "Transfer-Encoding"); - res_gdu->u.HTTP_Response = http_response; + res_gdu = o.create_HTTP_Response_details( + package.session(), + hreq, 404, + "http_client: no target URI specified"); } else { - res_gdu = o.create_HTTP_Response_details( - package.session(), - hreq, 502, - yaz_url_get_error(yaz_url)); + Z_HTTP_Response * http_response = + yaz_url_exec(yaz_url, uri.c_str(), hreq->method, + hreq->headers, hreq->content_buf, + hreq->content_len); + if (http_response) + { + res_gdu = o.create_HTTP_Response(package.session(), hreq, 200); + z_HTTP_header_remove(&http_response->headers, "Transfer-Encoding"); + res_gdu->u.HTTP_Response = http_response; + } + else + { + res_gdu = o.create_HTTP_Response_details( + package.session(), + hreq, 502, yaz_url_get_error(yaz_url)); + } } package.response() = res_gdu; yaz_url_destroy(yaz_url); -- 1.7.10.4