Skip to content

Commit

Permalink
[elasticsearch/proxy] use different code path with erorr
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Oct 19, 2016
1 parent e100e1f commit fec5e1a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/core_plugins/elasticsearch/lib/create_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ function createProxy(server, method, route, config) {
xforward: true,
timeout: server.config().get('elasticsearch.requestTimeout'),
onResponse: function (err, responseFromUpstream, request, reply) {
const upstreamLocation = responseFromUpstream.headers.location;
const response = reply(err, responseFromUpstream);
if (err) {
reply(err);
return;
}

// Workaround for #8705 until hapi has been updated to >= 15.0.0
if (upstreamLocation) {
delete responseFromUpstream.headers.location;
response.location(encodeURI(upstreamLocation));
if (responseFromUpstream.headers.location) {
// TODO: Workaround for #8705 until hapi has been updated to >= 15.0.0
responseFromUpstream.headers.location = encodeURI(responseFromUpstream.headers.location);
}

reply(null, responseFromUpstream);
}
}
},
Expand Down

0 comments on commit fec5e1a

Please sign in to comment.