Skip to content

Commit 6b0bf8f

Browse files
committed
address PR comments
1 parent 263745a commit 6b0bf8f

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

localstack-core/localstack/services/apigateway/next_gen/execute_api/integrations/http.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ def _get_default_headers(context: RestApiInvocationContext) -> dict[str, str]:
4444
"user-agent": f"AmazonAPIGateway_{context.api_id}",
4545
}
4646

47+
@staticmethod
48+
def _get_integration_timeout(integration: Integration) -> float:
49+
return int(integration.get("timeoutInMillis", 29000)) / 1000
50+
4751

4852
class RestApiHttpIntegration(BaseRestApiHttpIntegration):
4953
"""
@@ -70,8 +74,9 @@ def invoke(self, context: RestApiInvocationContext) -> Response:
7074
if method not in NO_BODY_METHODS:
7175
request_parameters["data"] = integration_req["body"]
7276

73-
# TODO: configurable timeout (29 by default)
74-
# request_parameters["timeout"] = 29
77+
# TODO: configurable timeout (29 by default) (check type and default value in provider)
78+
# integration: Integration = context.resource_method["methodIntegration"]
79+
# request_parameters["timeout"] = self._get_integration_timeout(integration)
7580
# TODO: check for redirects
7681
# request_parameters["allow_redirects"] = False
7782

@@ -128,6 +133,9 @@ def invoke(self, context: RestApiInvocationContext) -> Response:
128133
if method not in NO_BODY_METHODS:
129134
request_parameters["data"] = invocation_req["body"]
130135

136+
# TODO: configurable timeout (29 by default) (check type and default value in provider)
137+
# request_parameters["timeout"] = self._get_integration_timeout(integration)
138+
131139
request_response = requests.request(**request_parameters)
132140

133141
response_headers = Headers(dict(request_response.headers))

tests/aws/services/apigateway/test_apigateway_http.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,17 @@ def add_http_integration_transformers(snapshot):
4646
# TODO: shared between HTTP & HTTP_PROXY
4747
"$..content.headers.x-amzn-trace-id",
4848
"$..content.headers.x-forwarded-for",
49+
"$..headers.x-amz-apigw-id",
50+
"$..headers.x-amzn-trace-id",
4951
"$..content.origin",
5052
"$..headers.server",
53+
# TODO: only missing for HTTP
54+
"$..headers.x-amzn-requestid",
5155
# TODO: for HTTP integration only: requests (urllib3) automatically adds `Accept-Encoding` when sending the
5256
# request, seems like we cannot remove it
5357
"$..headers.accept-encoding",
54-
"$..headers.x-amz-apigw-id",
5558
# TODO: only missing for HTTP_PROXY
5659
"$..headers.x-amzn-remapped-x-amzn-requestid",
57-
"$..headers.x-amzn-trace-id",
58-
# TODO: only missing for HTTP
59-
"$..headers.x-amzn-requestid",
60-
"$..headers.x-amzn-trace-id",
6160
]
6261
)
6362
@markers.snapshot.skip_snapshot_verify(

0 commit comments

Comments
 (0)