Skip to content

Commit

Permalink
Use host from Jetty provided URI instead of Host header
Browse files Browse the repository at this point in the history
  • Loading branch information
mosiac1 committed Aug 12, 2024
1 parent a41fe9d commit a7bf7d6
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import io.trino.aws.proxy.spi.util.ImmutableMultiMap;
import io.trino.aws.proxy.spi.util.MultiMap;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.UriBuilder;
import org.glassfish.jersey.server.ContainerRequest;

import java.io.ByteArrayInputStream;
Expand Down Expand Up @@ -98,8 +97,7 @@ record BucketAndKey(String bucket, String rawKey) {}
BucketAndKey bucketAndKey = serverHostName
.flatMap(serverHostNameValue -> {
String lowercaseServerHostName = serverHostNameValue.toLowerCase(Locale.ROOT);
return headers.unmodifiedHeaders().getFirst("host")
.map(value -> UriBuilder.fromUri("http://" + value.toLowerCase(Locale.ROOT)).build().getHost())
return Optional.of(request.requestUri().getHost())
.filter(value -> value.endsWith(lowercaseServerHostName))
.map(value -> value.substring(0, value.length() - lowercaseServerHostName.length()))
.map(value -> value.endsWith(".") ? value.substring(0, value.length() - 1) : value);
Expand Down

0 comments on commit a7bf7d6

Please sign in to comment.