Skip to content

Commit b86bed2

Browse files
Liz BaldoLiz Baldo
authored andcommitted
copy fix over from PR #7822
1 parent f110f2a commit b86bed2

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

engine/src/main/scala/cromwell/webservice/SwaggerUiHttpService.scala

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,23 @@ trait SwaggerUiHttpService {
2323
| operationsSorter: "alpha"
2424
""".stripMargin
2525

26-
mapResponseEntity { entityFromJar =>
27-
entityFromJar.transformDataBytes(Flow.fromFunction[ByteString, ByteString] { original: ByteString =>
28-
ByteString(
29-
original.utf8String
30-
.replace("""url: "https://petstore.swagger.io/v2/swagger.json"""", "url: 'cromwell.yaml'")
31-
.replace("""layout: "StandaloneLayout"""", s"""layout: "StandaloneLayout", $swaggerOptions""")
32-
)
33-
})
26+
// Fix Issue #7763: Must intercept 304 BEFORE mapResponseEntity tries to transform it
27+
mapResponse { response =>
28+
if (response.status == StatusCodes.NotModified) {
29+
// For 304, return immediately with empty entity, don't try to transform
30+
response.withEntity(HttpEntity.Empty)
31+
} else {
32+
// For 200, transform the entity content
33+
response.mapEntity { entityFromJar =>
34+
entityFromJar.transformDataBytes(Flow.fromFunction[ByteString, ByteString] { original: ByteString =>
35+
ByteString(
36+
original.utf8String
37+
.replace("""url: "https://petstore.swagger.io/v2/swagger.json"""", "url: 'cromwell.yaml'")
38+
.replace("""layout: "StandaloneLayout"""", s"""layout: "StandaloneLayout", $swaggerOptions""")
39+
)
40+
})
41+
}
42+
}
3443
} {
3544
getFromResource(s"$resourceDirectory/index.html")
3645
}

0 commit comments

Comments
 (0)