Skip to content

Commit

Permalink
Add content-length header if we pass in a body to router test framewo…
Browse files Browse the repository at this point in the history
…rk (#434)
  • Loading branch information
adam-fowler authored May 6, 2024
1 parent a778e1d commit 91dbc92
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/HummingbirdTesting/RouterTestFramework.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ struct RouterTestFramework<Responder: HTTPResponder>: ApplicationTestFramework w

func executeRequest(uri: String, method: HTTPRequest.Method, headers: HTTPFields, body: ByteBuffer?) async throws -> TestResponse {
return try await withThrowingTaskGroup(of: TestResponse.self) { group in
var headers = headers
if let contentLength = body.map(\.readableBytes) {
headers[.contentLength] = String(describing: contentLength)
}
let (stream, source) = RequestBody.makeStream()
let request = Request(
head: .init(method: method, scheme: "http", authority: "localhost", path: uri, headerFields: headers),
Expand Down

0 comments on commit 91dbc92

Please sign in to comment.