Lambda ASP NET Core Server is returning Content-Type Header even on NoContent Response
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 68/100
调研方向
从 APIGatewayProxyFunction.MarshallResponse 中第 202 行附近及后续代码开始,然后使用 apigateway-aws-proxy Lambda template,通过返回 NoContent() 或 Ok() 的简单 GET endpoint 重现该响应。完成标准是:仅当响应包含内容时才将 Content-Type 写入 Headers 集合,并且 204 响应不存在 null 的 multiValueHeaders 条目。
由索引模型根据 Issue 内容生成。
描述
Description
We are using Amazon.Lambda.AspNetCoreServer 6.0.3 and normal ASP Net Controllers and responses.
The ActionResults for NoContent (HTTP 204) and Ok (HTTP 200) are correctly returning HTTP responses with a body and without a content-type header.
The ApiGatewayProxyFunction transforms that result into the following:
{
"statusCode": 204,
"headers": {},
"multiValueHeaders": {
"Content-Type": [
null
]
},
"body": "",
"isBase64Encoded": false
}
There is two Problems with this reponse:
- Content-Type can never be a multiValueHeader. The RFC (https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.2) states that.
- On 204 there should not even be a content-type header (and on 200 with an empty body, probably as well) See the RFC 7231 section 3.1.5.5 for that.
Reproduction Steps
Implement a simple GET Endpoint that returns either NoContent() or Ok() and call it e.g. via the AWS console and the Test Lambda Template for "apigateway-aws-proxy".
The response should be similar to the one above.
Environment
- Build Version: Amazon.Lambda.AspNetCoreServer 6.0.3
- OS Info: Lambda Image public.ecr.aws/lambda/dotnet:6-x86_64
- Build Environment: dotnet lambda toolchain (so SAM Templates)
- Targeted .NET Platform: .NET 6.0
Resolution
- 👋 I can/would-like-to implement a fix for this problem myself
The error should be in APIGatewayProxyFunction.MarshallResponse lines 202 and following.
Content-Type will need to be written to the Headers collection, but only if there is actually content in the response.
This is a 🐛 bug-report
- 主要语言
- C#
- 星标
- 1.7k
- 派生
- 505
- 平均合并
- 1 天 6 小时
- 30 天内合并 PR
- 10
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aws/aws-lambda-dotnet 的其他 Issue
-
feature-request needs-triage
难度 3/5 1-2 天 新手友好度 55/100
aws/aws-lambda-dotnet#2588 ·
维护者通常 1 天内回复
-
Generated XML doc `cref` contains unescaped generic arguments: CS1584 / CS1658 / CS1570 warnings可能已有人在做 @reginaldalfret 于 6 天前认领。 未关闭bug needs-triage
难度 3/5 1-2 天 新手友好度 68/100
aws/aws-lambda-dotnet#2587 ·
维护者通常 1 天内回复
-
bug needs-triage
难度 3/5 1-2 天 新手友好度 67/100
aws/aws-lambda-dotnet#2586 ·
维护者通常 1 天内回复
-
feature-request p2
难度 4/5 3-5 天 新手友好度 48/100
aws/aws-lambda-dotnet#2551 · 1 条评论 ·
维护者通常 1 天内回复
-
JSON log format pairs ILogger message template placeholders with state values by position, garbling ASP.NET Core hosting logs可能已有人在做 @Pybsama 于 77 天前认领。 未关闭bug investigating p2
难度 3/5 1-2 天 新手友好度 70/100
aws/aws-lambda-dotnet#2468 · 2 条评论 ·
维护者通常 1 天内回复
查看 aws/aws-lambda-dotnet 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
good first issue help wanted ready-for-human
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复
-
ready-for-agent size:S status:todo
难度 2/5 1-3 小时 新手友好度 82/100
elsa-workflows/elsa-foundation#2830 ·
维护者通常 1 天内回复
-
Review - Maintainer WG-Maintainers-Build
难度 2/5 1-3 小时 新手友好度 62/100
PowerShell/PowerShell#28220 · 1 条评论 ·
维护者通常 1 天内回复
-
area: docs eco: dotnet good first issue help wanted lane: free-agent roadmap size: XS type: docs
难度 2/5 1 小时以内 新手友好度 72/100
arminazimi/evergreen#377 ·
维护者通常 1 天内回复