Skip to content

implement new streamwriter api #291

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix warning
  • Loading branch information
artemredkin committed Aug 6, 2020
commit 30a7286fe419bccd99220ac927e8e90a4e22d87b
8 changes: 4 additions & 4 deletions Sources/AsyncHTTPClient/HTTPHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension HTTPClient {
///
/// - parameters:
/// - data: `IOData` to write.
@available(*, deprecated, message: "")
@available(*, deprecated, message: "StreamWriter is deprecated, please use StreamWriter2")
public func write(_ data: IOData) -> EventLoopFuture<Void> {
return self.closure(data)
}
Expand All @@ -64,11 +64,11 @@ extension HTTPClient {
}

public func write(_ buffer: ByteBuffer) -> EventLoopFuture<Void> {
self.onChunk(.byteBuffer(buffer))
return self.onChunk(.byteBuffer(buffer))
}

public func write(_ data: IOData) -> EventLoopFuture<Void> {
self.onChunk(data)
return self.onChunk(data)
}

public func write(_ buffer: ByteBuffer, promise: EventLoopPromise<Void>?) {
Expand All @@ -95,7 +95,7 @@ extension HTTPClient {
public var stream: (StreamWriter) -> EventLoopFuture<Void>
var stream2: ((StreamWriter2) -> Void)?

@available(*, deprecated, message: "")
@available(*, deprecated, message: "StreamWriter is deprecated, please use StreamWriter2")
init(length: Int?, stream: @escaping (StreamWriter) -> EventLoopFuture<Void>) {
self.length = length
self.stream = stream
Expand Down
1 change: 0 additions & 1 deletion Tests/AsyncHTTPClientTests/HTTPClientTests+XCTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ extension HTTPClientTests {
("testProxyPlaintextWithCorrectlyAuthorization", testProxyPlaintextWithCorrectlyAuthorization),
("testProxyPlaintextWithIncorrectlyAuthorization", testProxyPlaintextWithIncorrectlyAuthorization),
("testUploadStreaming", testUploadStreaming),
("testUploadStreaming2", testUploadStreaming2),
("testNoContentLengthForSSLUncleanShutdown", testNoContentLengthForSSLUncleanShutdown),
("testNoContentLengthWithIgnoreErrorForSSLUncleanShutdown", testNoContentLengthWithIgnoreErrorForSSLUncleanShutdown),
("testCorrectContentLengthForSSLUncleanShutdown", testCorrectContentLengthForSSLUncleanShutdown),
Expand Down
17 changes: 0 additions & 17 deletions Tests/AsyncHTTPClientTests/HTTPClientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -643,23 +643,6 @@ class HTTPClientTests: XCTestCase {
}

func testUploadStreaming() throws {
let body: HTTPClient.Body = .stream(length: 8) { writer in
let buffer = ByteBuffer(string: "1234")
return writer.write(.byteBuffer(buffer)).flatMap {
let buffer = ByteBuffer(string: "4321")
return writer.write(.byteBuffer(buffer))
}
}

let response = try self.defaultClient.post(url: self.defaultHTTPBinURLPrefix + "post", body: body).wait()
let bytes = response.body.flatMap { $0.getData(at: 0, length: $0.readableBytes) }
let data = try JSONDecoder().decode(RequestInfo.self, from: bytes!)

XCTAssertEqual(.ok, response.status)
XCTAssertEqual("12344321", data.data)
}

func testUploadStreaming2() throws {
let body: HTTPClient.Body = .stream2(length: 8) { writer in
var buffer = ByteBuffer(string: "1234")
writer.write(.byteBuffer(buffer), promise: nil)
Expand Down