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

WriteChunk API for HTTP1 #220

Merged
merged 10 commits into from
Jan 9, 2024
Merged

WriteChunk API for HTTP1 #220

merged 10 commits into from
Jan 9, 2024

Conversation

waahm7
Copy link
Contributor

@waahm7 waahm7 commented Jan 8, 2024

Issue #, if available:
#218
Description of changes:

  • Adds support for writeChunk API in HTTP1.
  • Adds unified writeChunk in HTTStream base class.
  • Update tests to use postman-echo instead of httpbin.

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

@@ -3,7 +3,7 @@
import AwsCHttp
import Foundation

/// An base class that represents a single Http Request/Response for both HTTP/1.1 and HTTP/2.
/// An base abstract class that represents a single Http Request/Response for both HTTP/1.1 and HTTP/2.
/// Can be used to update the Window size, and get status code.
public class HTTPStream {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about turning this class into a protocol to avoid the abstract class workaround with fatalAssert, but that would require making rawValue and callbackData variables public.

@waahm7 waahm7 requested a review from dayaffe January 8, 2024 21:44


/// This method must be overriden in each subclass.
public func writeChunk(chunk: Data, endOfStream: Bool) async throws {
Copy link
Contributor

Choose a reason for hiding this comment

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

mildly annoyed by calling this "chunk"
"chunk" is an HTTP/1-specific term

@@ -41,7 +41,12 @@ public class HTTPStream {
throw CommonRunTimeError.crtError(.makeFromLastError())
}
}


/// This method must be overriden in each subclass.
Copy link
Contributor

Choose a reason for hiding this comment

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

is this how interface functions are supposed to be documented? doesn't seem very useful to the user

Should this document how you have to set up the connection with "use manual data writes" or "transfer-encoding: chunked" depending on whether it's HTTP/1 or HTTP/2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the documentation to link to the H1 and H2 documentation.

@waahm7 waahm7 merged commit e9aca22 into main Jan 9, 2024
9 checks passed
@waahm7 waahm7 deleted the writeChunk branch January 9, 2024 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants