more compatibility fixes for s3cmd

s3cmd uses virtual hostname for bucket name, with the host header
including the port. need to strip out the port to find out the
bucket name
pull/22/merge
Ka-Hing Cheung 2014-11-18 00:53:36 -08:00 zatwierdzone przez Andrew Gaul
rodzic 004d12761e
commit 617b3ae3e9
1 zmienionych plików z 2 dodań i 0 usunięć

Wyświetl plik

@ -49,6 +49,7 @@ import com.google.common.collect.TreeMultimap;
import com.google.common.hash.HashCode;
import com.google.common.io.BaseEncoding;
import com.google.common.io.ByteStreams;
import com.google.common.net.HostAndPort;
import com.google.common.net.HttpHeaders;
import org.eclipse.jetty.server.Request;
@ -121,6 +122,7 @@ final class S3ProxyHandler extends AbstractHandler {
logger.debug("request: {}", request);
String hostHeader = request.getHeader(HttpHeaders.HOST);
if (hostHeader != null && virtualHost.isPresent()) {
hostHeader = HostAndPort.fromString(hostHeader).getHostText();
String virtualHostSuffix = "." + virtualHost.get();
if (hostHeader.endsWith(virtualHostSuffix)) {
String bucket = hostHeader.substring(0,