Skip to content

Commit 0bb4487

Browse files
LizBaldoLiz Baldo
andauthored
CTM-152: Copy fix over from PR #7822 (#7831)
Co-authored-by: Liz Baldo <[email protected]>
1 parent f110f2a commit 0bb4487

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cromwell.webservice
22

3-
import akka.http.scaladsl.model.{HttpResponse, StatusCodes}
3+
import akka.http.scaladsl.model.{HttpEntity, HttpResponse, StatusCodes}
44
import akka.http.scaladsl.server
55
import akka.http.scaladsl.server.Directives._
66
import akka.http.scaladsl.server.Route
@@ -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)