fix(s3): remove XML declaration from GetBucketLocation response (#403)

This commit is contained in:
Christine Nguyen authored and GitHub committed 2026-04-13 14:17:22 -05:00
1 parent 300bfa4356
commit 3621c32b88
2 files changed
+9 -7

No files matched your search

@@ -1147,17 +1147,17 @@ public class S3Controller {
private Response handleGetBucketLocation(String bucket) {
String region = s3Service.getBucketRegion(bucket);
XmlBuilder xml = new XmlBuilder()
.raw("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
String xml;
if (region == null || "us-east-1".equals(region)) {
xml.start("LocationConstraint", AwsNamespaces.S3)
.end("LocationConstraint");
xml = "<LocationConstraint xmlns=\"" + AwsNamespaces.S3 + "\"/>";
} else {
xml.start("LocationConstraint", AwsNamespaces.S3)
xml = new XmlBuilder()
.start("LocationConstraint", AwsNamespaces.S3)
.raw(XmlBuilder.escape(region))
.end("LocationConstraint");
.end("LocationConstraint")
.build();
}
return Response.ok(xml.build()).type(MediaType.APPLICATION_XML).build();
return Response.ok(xml).type(MediaType.APPLICATION_XML).build();
}
// --- Bucket Tagging ---