Commit d8edbb0
authored
Akka HTTP - Return HttpEntity.Strict as-is, do not convert to HttpEntity.Default (#4922)
Some response body types produce `HttpEntity.Strict` by using
`HttpEntity`
[constructor](https://github.com/softwaremill/tapir/blob/b001ab6ff176e36d5a34d0b5d0609bb9bdf91bf5/server/akka-http-server/src/main/scala/sttp/tapir/server/akkahttp/AkkaToResponseBody.scala#L50).
Advantage of `HttpEntity.Strict` is that the entity data (response in
this case) is available in a `ByteString`, which makes it easier when
one needs to implement a custom Akka HTTP directive that works with the
response data, for example a directive for custom response logging.
However, `AkkaBodyListener` matched this type as `UniversalEntity`, and
by calling `transformDataBytes`, the entity was converted to
`HttpEntity.Default`, which stores the data in a `Source`. However, to
obtain the response data from a `Source`, one basically needs to run a
Future and apply some timeout to make sure that obtaining response data
does not take too much time.
The purpose of this proposal is to keep `HttpEntity.Strict` as-is when
it is available.1 parent 4e2cc23 commit d8edbb0
File tree
2 files changed
+10
-0
lines changed- server
- akka-http-server/src/main/scala/sttp/tapir/server/akkahttp
- pekko-http-server/src/main/scala/sttp/tapir/server/pekkohttp
2 files changed
+10
-0
lines changedLines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| |||
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| |||
0 commit comments