Skip to content

feat(protocol-http): implement SRA HttpRequest #4514

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

Merged
merged 1 commit into from
Mar 13, 2023

Conversation

milesziemer
Copy link
Contributor

@milesziemer milesziemer commented Mar 10, 2023

Description

This change implements the core functionality of HttpRequest for SRA. New properties were added to the HttpRequest class, old properties and interfaces were deprecated. Proxy was added for headers and query properties to maintain backward compatibility. This change does not include updates to the SDK to use new functionality.

Notes on other changes:

  • middleware-host-header and middleware-sdk-transcribe-streaming tests: URL.port always returns '' if port is set to the default for the protocol.
  • middleware-sdk-transcribe-streaming: Providing URL.hostname with a string containing the port number does not update the port.
  • signature-v4 prepareRequest: See comment in code.
  • Field: toString method was changed to only require double quotes on values with commas. Current tests allow spaces without double quotes.
  • Fields: Helper methods were added for getting all fields and creating a Fields object.

Additional notes:

  • When converting between single string header values and a list of field values, split(",") and join(",") are used to avoid making any modifications to the original value, preserving compatibility.
  • HttpRequest.isInstance was not modified, because doing so might break compatibility. The check was not looking for the clone method, so wasn't actually verifying the object was indeed an instance. The method could easily have been used on a HttpRequest interface from the types package, and returned true.

Testing

yarn test:all

Additional context

Because custom middleware can have access to the HttpRequest object, Proxies, getters, and setters are being used
to allow old members of HttpRequest to be used.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@milesziemer milesziemer requested review from a team as code owners March 10, 2023 23:22
fields: Fields.from(
this.fields.getAll().map((field) => ({
...field,
values: [...field.values],
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps fields should implement clone. Hard to remember to do this every time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I thought about it. I figured we could implement it later if we needed it rather than exposing it now, but I don't have a strong opinion either way.

This change implements the core functionality of HttpRequest for SRA.
New properties were added to the HttpRequest class, old properties
and interfaces were deprecated. Proxy was added for headers and query
properties to maintain backward compatibility. This change does not
include updates to the SDK to use new functionality.

Notes on other changes:
* middleware-host-header and middleware-sdk-transcribe-streaming tests:
  URL.port always returns '' if port is set to the default for the
protocol.
* middleware-sdk-transcribe-streaming: Providing URL.hostname with a
  string containing the port number does not update the port.
* signature-v4 prepareRequest: See comment in code.
* Field: toString method was changed to only require double quotes on
  values with commas. Current tests allow spaces without double quotes.
* Fields: Helper methods were added for getting all fields and creating
  a Fields object.

Additional notes:
* When converting between single string header values and a list of
  field values, split(",") and join(",") are used to avoid making any
modifications to the original value, preserving compatibility.
* HttpRequest.isInstance was not modified, because doing so might break
  compatibility. The check was not looking for the clone method, so
wasn't actually verifying the object was indeed an instance. The method
could easily have been used on a HttpRequest interface from the types
package, and returned true.
@kuhe kuhe merged commit d9d24b0 into aws:main Mar 13, 2023
milesziemer added a commit to milesziemer/aws-sdk-js-v3 that referenced this pull request Mar 14, 2023
This reverts commit d9d24b0.
A bug was found with this commit when using a Symbol as a key, or
a non-string as a value in `request.headers`.
milesziemer added a commit to milesziemer/aws-sdk-js-v3 that referenced this pull request Mar 15, 2023
This reverts commit d9d24b0.
A bug was found with this commit when using a Symbol as a key, or
a non-string as a value in `request.headers`.
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants