Handle empty header values in Authorization

Found with Ceph s3-tests.  References #5.
pull/16/head
Andrew Gaul 2014-07-30 01:00:47 -07:00
rodzic f7db3ee4fb
commit 1e7a4a2270
1 zmienionych plików z 9 dodań i 4 usunięć

Wyświetl plik

@ -23,6 +23,7 @@ import java.io.Writer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.Enumeration; import java.util.Enumeration;
@ -679,14 +680,18 @@ final class S3ProxyHandler extends AbstractHandler {
SortedSetMultimap<String, String> canonicalizedHeaders = SortedSetMultimap<String, String> canonicalizedHeaders =
TreeMultimap.create(); TreeMultimap.create();
for (String headerName : Collections.list(request.getHeaderNames())) { for (String headerName : Collections.list(request.getHeaderNames())) {
Collection<String> headerValues = Collections.list(
request.getHeaders(headerName));
headerName = headerName.toLowerCase(); headerName = headerName.toLowerCase();
if (!headerName.startsWith("x-amz-")) { if (!headerName.startsWith("x-amz-")) {
continue; continue;
} }
for (String headerValue : Collections.list(request.getHeaders( if (headerValues.isEmpty()) {
headerName))) { canonicalizedHeaders.put(headerName, "");
canonicalizedHeaders.put(headerName, Strings.nullToEmpty( }
headerValue)); for (String headerValue : headerValues) {
canonicalizedHeaders.put(headerName,
Strings.nullToEmpty(headerValue));
} }
} }