Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create a valid URL for REST APIs and ALBs when the host header i… #369

Merged
merged 2 commits into from
Nov 20, 2021

Conversation

nmoutschen
Copy link
Contributor

…s missing

Issue #, if available: #368

Description of changes:

When the Host header is missing from an API Gateway REST API or ALB request, the current implementations defaults to an empty value. This means that the lambda_http crate tries to transform a value of https:///my/path into an Uri, which results in an http::Error(InvalidUri(InvalidFormat)) error.

This PR changes the behavior by checking first if there is a valid host header present. It then uses the http(s)://my-host/my/path pattern if it is present, or just /my/path otherwise.

No changes are needed for API Gateway v2 since it adds a requestContext.domainName value, which means we can always derive a valid domain name in that situation.

By submitting this pull request

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I confirm that I've made a best effort attempt to update all relevant documentation.

Copy link
Contributor

@coltonweaver coltonweaver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing!

@coltonweaver coltonweaver merged commit eeb849b into awslabs:master Nov 20, 2021
@nmoutschen nmoutschen deleted the apigw-no-host branch November 21, 2021 09:58
@nmoutschen nmoutschen added the 0.5 label Feb 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants