fix(lambda): stream the body of a RESPONSE_STREAM function URL (#7885)

* fix(lambda): return the streamed body from a RESPONSE_STREAM function URL

A function URL in RESPONSE_STREAM mode parsed only the HttpResponseStream
prelude and dropped the body written after its eight NUL bytes, so callers got
the status and headers with an empty body. Split the stream at the delimiter
and return the rest as the body; a stream without a prelude is a 200
application/octet-stream, as on AWS. The stream is still buffered.

Closes #7837

* fix(lambda): stream the body of a RESPONSE_STREAM function URL as it is written

The runtime API now hands a streamed response to the invocation chunk by chunk,
ahead of the BodyHandler that buffers every other response, and completes the
invocation only when the stream ends, so the timeout, the concurrency permit
and the container stay held for the whole stream. The function URL answers as
soon as the head is known and writes each chunk as it arrives. The prelude is
read only when the stream's content type is
application/vnd.awslambda.http-integration-response; any other stream keeps
the content type the handler set.

* fix(lambda): check the streamed function URL response without timing it

The runtime API and controller tests pin chunk-by-chunk delivery, so the
end-to-end test only checks the status, content type and body.
This commit is contained in:
Niels Kootstra authored and GitHub committed 2026-11-10 11:54:40 -04:00
1 parent 8d95688eec
commit 65b09d0aac
11 files changed
+560 -16

No files matched your search

+2
View File
@@ -429,6 +429,8 @@ disabled fails with Lambda's error as the resource status reason.
Function URLs are also reachable directly on `/{proxy:.*}` under the Lambda URL controller, which routes the request into the normal `Invoke` path.
A function URL with `InvokeMode: RESPONSE_STREAM` streams the response: each chunk the handler writes reaches the caller as it is written. When the handler uses `awslambda.HttpResponseStream.from`, the status code, headers and cookies come from its prelude. Otherwise the response is a `200` with the content type the handler set, `application/octet-stream` by default. A function that fails before its stream starts, in its init or by timing out, answers `502`. An error the handler throws ends the body where it stopped, an empty `200` if it wrote nothing: the runtime reports it in HTTP trailers, which Floci's runtime API does not read. A handler that does not stream is answered as with `BUFFERED`.
Function URLs are not available in AWS GovCloud (US) or in the China Regions
([GovCloud guide](https://docs.aws.amazon.com/govcloud-us/latest/UserGuide/govcloud-lambda.html),
[China guide](https://docs.amazonaws.cn/en_us/aws/latest/userguide/lambda.html)), so