#3991 - AWSLambda - set content-type to app/json (#4046)

This commit is contained in:
Bert Blommers 2021-06-30 11:02:38 +01:00 committed by GitHub
parent 163ae322e8
commit 8cc439444f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -209,6 +209,7 @@ class LambdaResponse(BaseResponse):
function_name, qualifier, self.body, self.headers, response_headers
)
if payload:
response_headers["content-type"] = "application/json"
if request.headers.get("X-Amz-Invocation-Type") == "Event":
status_code = 202
elif request.headers.get("X-Amz-Invocation-Type") == "DryRun":

View File

@ -157,6 +157,9 @@ def test_invoke_requestresponse_function(invocation_type):
assert False, success_result["Payload"].read().decode("utf-8")
success_result["StatusCode"].should.equal(200)
success_result["ResponseMetadata"]["HTTPHeaders"]["content-type"].should.equal(
"application/json"
)
logs = base64.b64decode(success_result["LogResult"]).decode("utf-8")
logs.should.contain("START RequestId:")
@ -172,6 +175,9 @@ def test_invoke_requestresponse_function(invocation_type):
)
success_result["StatusCode"].should.equal(200)
success_result["ResponseMetadata"]["HTTPHeaders"]["content-type"].should.equal(
"application/json"
)
assert "LogResult" not in success_result