mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(apigateway): answer an HTTP API proxy result without a Content-Type as text/plain (#6201)
* fix(apigateway): answer an HTTP API proxy result without a Content-Type as text/plain Measured on AWS (eu-west-1, 2026-10-19): an HTTP API answers a Lambda proxy result that carries a body and no Content-Type header of its own with text/plain; charset=utf-8, in both payload formats. Floci fell back to application/json, the REST API's default, so a client that trusts the header read a plain body as JSON. The fallback now follows the API kind: an HTTP API answers text/plain, a REST API keeps answering application/json. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> * test(apigateway): fold the Content-Type cases into the inference test The three cases repeated the inference test's setup, route helper and cleanup, so they join it: two results without a Content-Type in the two payload formats, and one that names application/json. The docs say a statusCode and a body, since a format 2.0 result without a statusCode still takes the inferred JSON path, and the compatibility test's get helper and parameterized name are back on one line each. Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com> --------- Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
This commit is contained in:
1 parent
b58947c70a
commit
34f592f7e7
5 files changed
+98
-7
No files matched your search
+6
-1
@@ -1608,6 +1608,11 @@ public class ApiGatewayExecuteController {
|
||||
return buildProxyResponse(result, httpApiV2, httpApiV2);
|
||||
}
|
||||
|
||||
// The Content-Type an HTTP API answers with when the function's result carries a body and no
|
||||
// Content-Type header of its own (measured on AWS, eu-west-1, 2026-10-19, in both payload
|
||||
// formats). A REST API keeps answering application/json.
|
||||
private static final String HTTP_API_DEFAULT_CONTENT_TYPE = "text/plain; charset=utf-8";
|
||||
|
||||
// httpApi selects the HTTP API error response; payloadV2 selects the integration's format 2.0
|
||||
// response rules (inference and cookies). An HTTP API integration can still use format 1.0.
|
||||
Response buildProxyResponse(InvokeResult result, boolean httpApi, boolean payloadV2) {
|
||||
@@ -1670,7 +1675,7 @@ public class ApiGatewayExecuteController {
|
||||
byte[] bytes = base64 ? Base64.getDecoder().decode(bodyStr) : bodyStr.getBytes();
|
||||
String ct = findHeaderIgnoreCase(multiHeaders, "Content-Type")
|
||||
.or(() -> findHeaderIgnoreCase(respHeaders, "Content-Type"))
|
||||
.orElse(MediaType.APPLICATION_JSON);
|
||||
.orElse(httpApi ? HTTP_API_DEFAULT_CONTENT_TYPE : MediaType.APPLICATION_JSON);
|
||||
builder.entity(bytes).type(ct);
|
||||
}
|
||||
return builder.build();
|
||||
|
||||
Reference in new issue
Block a user