Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Lambda ASP NET Core Server is returning Content-Type Header even on NoContent Response

未关闭 适合新手
#1,123 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
aws, csharp
领域
api, backend, cloud

调研方向

从 APIGatewayProxyFunction.MarshallResponse 中第 202 行附近及后续代码开始,然后使用 apigateway-aws-proxy Lambda template,通过返回 NoContent() 或 Ok() 的简单 GET endpoint 重现该响应。完成标准是:仅当响应包含内容时才将 Content-Type 写入 Headers 集合,并且 204 响应不存在 null 的 multiValueHeaders 条目。

由索引模型根据 Issue 内容生成。

描述

bug module/aspnetcore-support p2 queued

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:

  1. Content-Type can never be a multiValueHeader. The RFC (https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.2) states that.
  2. 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aws/aws-lambda-dotnet 的其他 Issue

查看 aws/aws-lambda-dotnet 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。