Skip to content

Commit

Permalink
Merge branch 'main' into mahdibm-add-as-contentdecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
0xTim committed May 30, 2023
2 parents da11309 + f0aed18 commit dd71055
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Support Vapor's development by [becoming a sponsor](https://github.com/sponsors/
### 💚 Backers
Support Vapor's development by [becoming a backer](https://github.com/sponsors/vapor).

<!-- backers --><a href="https://github.com/slashmo"><img src="https://github.com/slashmo.png" width="60px" alt="Moritz Lang" /></a><a href="https://github.com/maartene"><img src="https://github.com/maartene.png" width="60px" alt="Maarten Engels" /></a><a href="https://github.com/tkrajacic"><img src="https://github.com/tkrajacic.png" width="60px" alt="Thomas Krajacic" /></a><a href="https://github.com/jessetipton"><img src="https://github.com/jessetipton.png" width="60px" alt="Jesse Tipton" /></a><a href="https://github.com/steve-h"><img src="https://github.com/steve-h.png" width="60px" alt="Steve Hume" /></a><a href="https://github.com/mikkelu"><img src="https://github.com/mikkelu.png" width="60px" alt="Mikkel Ulstrup" /></a><a href="https://github.com/g-Off"><img src="https://github.com/g-Off.png" width="60px" alt="Geoffrey Foster" /></a><a href="https://github.com/PSchmiedmayer"><img src="https://github.com/PSchmiedmayer.png" width="60px" alt="Paul Schmiedmayer" /></a><a href="https://github.com/ScottRobbins"><img src="https://github.com/ScottRobbins.png" width="60px" alt="Scott Robbins" /></a><a href="https://github.com/finestructure"><img src="https://github.com/finestructure.png" width="60px" alt="Sven A. Schmidt" /></a><a href="https://github.com/SpencerCurtis"><img src="https://github.com/SpencerCurtis.png" width="60px" alt="Spencer Curtis" /></a><a href="https://github.com/0xLeif"><img src="https://github.com/0xLeif.png" width="60px" alt="Zach" /></a><a href="https://github.com/rausnitz"><img src="https://github.com/rausnitz.png" width="60px" alt="Zach Rausnitz" /></a><a href="https://github.com/masterofinsanity"><img src="https://github.com/masterofinsanity.png" width="60px" alt="Tim „Timinator“ Kretzschmar" /></a><a href="https://github.com/klaas"><img src="https://github.com/klaas.png" width="60px" alt="Klaas" /></a><a href="https://github.com/Andrewangeta"><img src="https://github.com/Andrewangeta.png" width="60px" alt="Andrew Edwards" /></a><a href="https://github.com/addli"><img src="https://github.com/addli.png" width="60px" alt="+Li, Inc." /></a><a href="https://github.com/doozMen"><img src="https://github.com/doozMen.png" width="60px" alt="Stijn Willems" /></a><a href="https://github.com/bitwit"><img src="https://github.com/bitwit.png" width="60px" alt="Kyle Newsome" /></a><a href="https://github.com/viaaurelia"><img src="https://github.com/viaaurelia.png" width="60px" alt="Via Aurelia Solutions" /></a><a href="https://github.com/kkiermasz"><img src="https://github.com/kkiermasz.png" width="60px" alt="Jakub Kiermasz" /></a><a href="https://github.com/bdrelling"><img src="https://github.com/bdrelling.png" width="60px" alt="Brian Drelling" /></a><a href="https://github.com/mayondigital"><img src="https://github.com/mayondigital.png" width="60px" alt="" /></a><a href="https://github.com/mattesmohr"><img src="https://github.com/mattesmohr.png" width="60px" alt="Mattes Mohr" /></a><a href="https://github.com/scibidoo"><img src="https://github.com/scibidoo.png" width="60px" alt="Jamie" /></a><a href="https://github.com/GalenRhodes"><img src="https://github.com/GalenRhodes.png" width="60px" alt="Galen Rhodes" /></a><a href="https://github.com/litmaps"><img src="https://github.com/litmaps.png" width="60px" alt="Litmaps" /></a><a href="https://github.com/davdroman"><img src="https://github.com/davdroman.png" width="60px" alt="David Roman" /></a><a href="https://github.com/Strobocop"><img src="https://github.com/Strobocop.png" width="60px" alt="Brian Strobach" /></a><a href="https://github.com/j4nos"><img src="https://github.com/j4nos.png" width="60px" alt="János" /></a><a href="https://github.com/tristanbiesecker"><img src="https://github.com/tristanbiesecker.png" width="60px" alt="Tristan Biesecker" /></a><a href="https://github.com/kishikawakatsumi"><img src="https://github.com/kishikawakatsumi.png" width="60px" alt="Kishikawa Katsumi" /></a><a href="https://github.com/mkll"><img src="https://github.com/mkll.png" width="60px" alt="Alex Sherbakov" /></a><a href="https://github.com/getsidetrack"><img src="https://github.com/getsidetrack.png" width="60px" alt="Sidetrack" /></a><a href="https://github.com/GregKarpati"><img src="https://github.com/GregKarpati.png" width="60px" alt="Greg Karpati" /></a><a href="https://github.com/fananek"><img src="https://github.com/fananek.png" width="60px" alt="František Mikš" /></a><a href="https://github.com/jagreenwood"><img src="https://github.com/jagreenwood.png" width="60px" alt="Jeremy Greenwood" /></a><a href="https://github.com/MerchV"><img src="https://github.com/MerchV.png" width="60px" alt="Merch Visoiu" /></a><a href="https://github.com/rayfix"><img src="https://github.com/rayfix.png" width="60px" alt="Ray Fix" /></a><a href="https://github.com/micomiloloza"><img src="https://github.com/micomiloloza.png" width="60px" alt="Mićo Miloloža" /></a><a href="https://github.com/Suboptimierer"><img src="https://github.com/Suboptimierer.png" width="60px" alt="Jonas Sannewald" /></a><a href="https://github.com/TapEnvy-us-LLC"><img src="https://github.com/TapEnvy-us-LLC.png" width="60px" alt="TapEnvy.us, LLC" /></a><a href="https://github.com/JawadHF"><img src="https://github.com/JawadHF.png" width="60px" alt="Jawad" /></a><a href="https://github.com/getsentry"><img src="https://github.com/getsentry.png" width="60px" alt="Sentry" /></a><a href="https://github.com/darthregor"><img src="https://github.com/darthregor.png" width="60px" alt="" /></a><a href="https://github.com/mikhaildudarev"><img src="https://github.com/mikhaildudarev.png" width="60px" alt="Mikhail Dudarev" /></a><a href="https://github.com/PARAIPAN9"><img src="https://github.com/PARAIPAN9.png" width="60px" alt="PARAIPAN SORIN" /></a><!-- backers -->
<!-- backers --><a href="https://github.com/slashmo"><img src="https://github.com/slashmo.png" width="60px" alt="Moritz Lang" /></a><a href="https://github.com/maartene"><img src="https://github.com/maartene.png" width="60px" alt="Maarten Engels" /></a><a href="https://github.com/tkrajacic"><img src="https://github.com/tkrajacic.png" width="60px" alt="Thomas Krajacic" /></a><a href="https://github.com/jessetipton"><img src="https://github.com/jessetipton.png" width="60px" alt="Jesse Tipton" /></a><a href="https://github.com/steve-h"><img src="https://github.com/steve-h.png" width="60px" alt="Steve Hume" /></a><a href="https://github.com/mikkelu"><img src="https://github.com/mikkelu.png" width="60px" alt="Mikkel Ulstrup" /></a><a href="https://github.com/g-Off"><img src="https://github.com/g-Off.png" width="60px" alt="Geoffrey Foster" /></a><a href="https://github.com/PSchmiedmayer"><img src="https://github.com/PSchmiedmayer.png" width="60px" alt="Paul Schmiedmayer" /></a><a href="https://github.com/ScottRobbins"><img src="https://github.com/ScottRobbins.png" width="60px" alt="Scott Robbins" /></a><a href="https://github.com/finestructure"><img src="https://github.com/finestructure.png" width="60px" alt="Sven A. Schmidt" /></a><a href="https://github.com/SpencerCurtis"><img src="https://github.com/SpencerCurtis.png" width="60px" alt="Spencer Curtis" /></a><a href="https://github.com/0xLeif"><img src="https://github.com/0xLeif.png" width="60px" alt="Zach" /></a><a href="https://github.com/rausnitz"><img src="https://github.com/rausnitz.png" width="60px" alt="Zach Rausnitz" /></a><a href="https://github.com/masterofinsanity"><img src="https://github.com/masterofinsanity.png" width="60px" alt="Tim „Timinator“ Kretzschmar" /></a><a href="https://github.com/klaas"><img src="https://github.com/klaas.png" width="60px" alt="Klaas" /></a><a href="https://github.com/Andrewangeta"><img src="https://github.com/Andrewangeta.png" width="60px" alt="Andrew Edwards" /></a><a href="https://github.com/addli"><img src="https://github.com/addli.png" width="60px" alt="+Li, Inc." /></a><a href="https://github.com/doozMen"><img src="https://github.com/doozMen.png" width="60px" alt="Stijn Willems" /></a><a href="https://github.com/bitwit"><img src="https://github.com/bitwit.png" width="60px" alt="Kyle Newsome" /></a><a href="https://github.com/viaaurelia"><img src="https://github.com/viaaurelia.png" width="60px" alt="Via Aurelia Solutions" /></a><a href="https://github.com/kkiermasz"><img src="https://github.com/kkiermasz.png" width="60px" alt="Jakub Kiermasz" /></a><a href="https://github.com/bdrelling"><img src="https://github.com/bdrelling.png" width="60px" alt="Brian Drelling" /></a><a href="https://github.com/mayondigital"><img src="https://github.com/mayondigital.png" width="60px" alt="" /></a><a href="https://github.com/mattesmohr"><img src="https://github.com/mattesmohr.png" width="60px" alt="Mattes Mohr" /></a><a href="https://github.com/scibidoo"><img src="https://github.com/scibidoo.png" width="60px" alt="Jamie" /></a><a href="https://github.com/GalenRhodes"><img src="https://github.com/GalenRhodes.png" width="60px" alt="Galen Rhodes" /></a><a href="https://github.com/litmaps"><img src="https://github.com/litmaps.png" width="60px" alt="Litmaps" /></a><a href="https://github.com/davdroman"><img src="https://github.com/davdroman.png" width="60px" alt="David Roman" /></a><a href="https://github.com/Strobocop"><img src="https://github.com/Strobocop.png" width="60px" alt="Brian Strobach" /></a><a href="https://github.com/j4nos"><img src="https://github.com/j4nos.png" width="60px" alt="János" /></a><a href="https://github.com/tristanbiesecker"><img src="https://github.com/tristanbiesecker.png" width="60px" alt="Tristan Biesecker" /></a><a href="https://github.com/kishikawakatsumi"><img src="https://github.com/kishikawakatsumi.png" width="60px" alt="Kishikawa Katsumi" /></a><a href="https://github.com/mkll"><img src="https://github.com/mkll.png" width="60px" alt="Alex Sherbakov" /></a><a href="https://github.com/getsidetrack"><img src="https://github.com/getsidetrack.png" width="60px" alt="Sidetrack" /></a><a href="https://github.com/GregKarpati"><img src="https://github.com/GregKarpati.png" width="60px" alt="Greg Karpati" /></a><a href="https://github.com/fananek"><img src="https://github.com/fananek.png" width="60px" alt="František Mikš" /></a><a href="https://github.com/jagreenwood"><img src="https://github.com/jagreenwood.png" width="60px" alt="Jeremy Greenwood" /></a><a href="https://github.com/MerchV"><img src="https://github.com/MerchV.png" width="60px" alt="Merch Visoiu" /></a><a href="https://github.com/rayfix"><img src="https://github.com/rayfix.png" width="60px" alt="Ray Fix" /></a><a href="https://github.com/micomiloloza"><img src="https://github.com/micomiloloza.png" width="60px" alt="Mićo Miloloža" /></a><a href="https://github.com/Suboptimierer"><img src="https://github.com/Suboptimierer.png" width="60px" alt="Jonas Sannewald" /></a><a href="https://github.com/TapEnvy-us-LLC"><img src="https://github.com/TapEnvy-us-LLC.png" width="60px" alt="TapEnvy.us, LLC" /></a><a href="https://github.com/JawadHF"><img src="https://github.com/JawadHF.png" width="60px" alt="Jawad" /></a><a href="https://github.com/getsentry"><img src="https://github.com/getsentry.png" width="60px" alt="Sentry" /></a><a href="https://github.com/darthregor"><img src="https://github.com/darthregor.png" width="60px" alt="" /></a><a href="https://github.com/PARAIPAN9"><img src="https://github.com/PARAIPAN9.png" width="60px" alt="PARAIPAN SORIN" /></a><!-- backers -->

<a href="https://opencollective.com/vapor/backer/0/website" target="_blank"><img src="https://opencollective.com/vapor/backer/0/avatar.svg"></a>
<a href="https://opencollective.com/vapor/backer/1/website" target="_blank"><img src="https://opencollective.com/vapor/backer/1/avatar.svg"></a>
Expand Down
4 changes: 3 additions & 1 deletion Sources/Vapor/Request/Request+Body.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ extension Request {
}
case .collected(let buffer):
_ = handler(.buffer(buffer))
_ = handler(.end)
.map {
handler(.end)
}
case .none:
_ = handler(.end)
}
Expand Down
31 changes: 31 additions & 0 deletions Tests/VaporTests/RequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,35 @@ final class RequestTests: XCTestCase {
.temporaryRedirect
)
}

func testCollectedBodyDrain() throws {
let app = Application()
defer { app.shutdown() }

let request = Request(
application: app,
collectedBody: .init(string: ""),
on: EmbeddedEventLoop()
)

let handleBufferExpectation = XCTestExpectation()
let endDrainExpectation = XCTestExpectation()

request.body.drain { part in
switch part {
case .buffer:
return request.eventLoop.makeFutureWithTask {
handleBufferExpectation.fulfill()
}
case .error:
XCTAssertTrue(false)
return request.eventLoop.makeSucceededVoidFuture()
case .end:
endDrainExpectation.fulfill()
return request.eventLoop.makeSucceededVoidFuture()
}
}

self.wait(for: [handleBufferExpectation, endDrainExpectation], timeout: 1.0, enforceOrder: true)
}
}

0 comments on commit dd71055

Please sign in to comment.