Return the body of a send that saved nothing

Replaces the response-directory fallback with what the frontend already
does for ephemeral sends: the engine hands the body back, because it is
the only copy. Guessing at a file named for an id was the store reaching
around its own abstraction, and it is exactly what must not survive the
move to blob storage.

The send reply carries the bytes when the engine returned them, and the
runtime holds them for the rest of the call that sent them, so
ctx.httpResponse.body() answers for a saved and an unsaved response the
same way. Unsaved ones now report a real contentType too, taken from the
response the send already handed back.
This commit is contained in:
Gregory Schier
2026-08-16 09:54:56 -07:00
parent 8b031db685
commit ffa6a610b8
10 changed files with 128 additions and 80 deletions
+10 -1
View File
@@ -557,7 +557,16 @@ export type RenderPurpose = "send" | "preview";
export type SendHttpRequestRequest = { httpRequest: Partial<HttpRequest>, };
export type SendHttpRequestResponse = { httpResponse: HttpResponse, };
export type SendHttpRequestResponse = { httpResponse: HttpResponse,
/**
* The body, base64, when the send saved nothing.
*
* A request with no id behind it produces a response the model store never
* sees, so it cannot be read back by id later the way a saved one can.
* This is the only copy of it. `None` means the body was stored and should
* be read with `read_http_response_body_chunk_request`.
*/
body?: string | null, };
export type SetKeyValueRequest = { key: string, value: string, };
@@ -184,6 +184,11 @@ export interface Context {
* Read a response's body by id. Where the host keeps the bytes — files on
* a desktop, rows in a database, somewhere else later — is not something a
* plugin sees or should depend on.
*
* Works for any response the host saved, and for one that `send` returned
* without saving — those are held for the rest of the call that sent them,
* since nothing else has a copy. Reaching for an unsaved response's id in a
* later call throws, because by then its bytes are gone.
*/
body(args: GetHttpResponseBodyInfoRequest): Promise<HttpResponseBody>;
};