Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import io.druid.server.router.Router;
import io.druid.server.security.AuthConfig;
import io.druid.server.security.Escalator;
import org.apache.http.client.utils.URIBuilder;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.client.api.Response;
Expand All @@ -58,10 +59,8 @@
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -331,15 +330,15 @@ protected URI rewriteURI(HttpServletRequest request, String scheme, String host)
protected static URI makeURI(String scheme, String host, String requestURI, String rawQueryString)
{
try {
return new URI(
scheme,
host,
requestURI,
rawQueryString == null ? null : URLDecoder.decode(rawQueryString, "UTF-8"),
null
);
return new URIBuilder()
.setScheme(scheme)
.setHost(host)
.setPath(requestURI)
// No need to encode-decode queryString, it is already encoded
.setQuery(rawQueryString)
.build();
}
catch (UnsupportedEncodingException | URISyntaxException e) {
catch (URISyntaxException e) {
log.error(e, "Unable to rewrite URI [%s]", e.getMessage());
throw Throwables.propagate(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
import io.druid.server.router.QueryHostFinder;
import io.druid.server.router.RendezvousHashAvaticaConnectionBalancer;
import io.druid.server.security.AllowAllAuthorizer;
import io.druid.server.security.NoopEscalator;
import io.druid.server.security.Authorizer;
import io.druid.server.security.AuthorizerMapper;
import io.druid.server.security.NoopEscalator;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
Expand Down Expand Up @@ -308,6 +308,19 @@ public void testRewriteURI() throws Exception
new URI("http://localhost/"),
AsyncQueryForwardingServlet.makeURI("http", "localhost", "/", null)
);

// Test reWrite Encoded interval with timezone info
// decoded parameters 1900-01-01T00:00:00.000+01.00 -> 1900-01-01T00:00:00.000+01:00
Assert.assertEquals(
new URI(
"http://localhost:1234/some/path?intervals=1900-01-01T00%3A00%3A00.000%2B01%3A00%2F3000-01-01T00%3A00%3A00.000%2B01%3A00"),
AsyncQueryForwardingServlet.makeURI(
"http",
"localhost:1234",
"/some/path",
"intervals=1900-01-01T00%3A00%3A00.000%2B01%3A00%2F3000-01-01T00%3A00%3A00.000%2B01%3A00"
)
);
}

private static class TestServer implements io.druid.client.selector.Server
Expand Down