Lambda ASP NET Core Server is returning Content-Type Header even on NoContent Response
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 68/100
Direzione di ricerca
Inizia in APIGatewayProxyFunction.MarshallResponse intorno alla riga 202 e a quelle successive, quindi riproduci la risposta con un semplice endpoint GET che restituisca NoContent() o Ok() usando il template Lambda apigateway-aws-proxy. Il lavoro è completato quando Content-Type viene scritto nella raccolta Headers solo se la risposta contiene contenuto, senza alcuna voce null di multiValueHeaders per una risposta 204.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- C#
- Stelle
- 1.7k
- Fork
- 504
- Merge medio
- 2g 9h
- PR unite (30g)
- 9
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws/aws-lambda-dotnet
-
Annotate auto-generated codeApertafeature-request needs-triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
aws/aws-lambda-dotnet#2588 ·
I maintainer di solito rispondono entro 1 giorno
-
Generated XML doc `cref` contains unescaped generic arguments: CS1584 / CS1658 / CS1570 warningsForse già presa @reginaldalfret l’ha presa 4 giorni fa. Apertabug needs-triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
aws/aws-lambda-dotnet#2587 ·
I maintainer di solito rispondono entro 1 giorno
-
bug needs-triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 67/100
aws/aws-lambda-dotnet#2586 ·
I maintainer di solito rispondono entro 1 giorno
-
feature-request p2
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
aws/aws-lambda-dotnet#2551 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
JSON log format pairs ILogger message template placeholders with state values by position, garbling ASP.NET Core hosting logsForse già presa @Pybsama l’ha presa 75 giorni fa. Apertabug investigating p2
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
aws/aws-lambda-dotnet#2468 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di aws/aws-lambda-dotnet
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
area:re1 bounty help wanted needs-game
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
StackExchange/StackExchange.Redis#3274 ·
I maintainer di solito rispondono entro 1 giorno
-
affected/v17 affected/v18 area/frontend type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
umbraco/Umbraco-CMS#24186 ·
I maintainer di solito rispondono entro 2 giorni