diff --git a/src/HTTPure/Body.purs b/src/HTTPure/Body.purs index 445e2a2..0090c04 100644 --- a/src/HTTPure/Body.purs +++ b/src/HTTPure/Body.purs @@ -42,9 +42,10 @@ instance bodyString :: Body String where Aff.makeAff \done -> do let stream = HTTP.responseAsStream response - _ <- Stream.writeString stream Encoding.UTF8 body $ pure unit - _ <- Stream.end stream $ pure unit - done $ Either.Right unit + void $ Stream.writeString stream Encoding.UTF8 body + $ Stream.end stream + $ done + $ Either.Right unit pure Aff.nonCanceler -- | The instance for `Buffer` is trivial--we add a `Content-Length` header @@ -56,9 +57,10 @@ instance bodyBuffer :: Body Buffer.Buffer where Aff.makeAff \done -> do let stream = HTTP.responseAsStream response - _ <- Stream.write stream body $ pure unit - _ <- Stream.end stream $ pure unit - done $ Either.Right unit + void $ Stream.write stream body + $ Stream.end stream + $ done + $ Either.Right unit pure Aff.nonCanceler -- | This instance can be used to send chunked data. Here, we add a @@ -72,7 +74,7 @@ instance bodyChunked :: Aff.makeAff \done -> do let stream = TypeEquals.to body - _ <- Stream.pipe stream $ HTTP.responseAsStream response + void $ Stream.pipe stream $ HTTP.responseAsStream response Stream.onEnd stream $ done $ Either.Right unit pure Aff.nonCanceler diff --git a/test/Test/HTTPure/ResponseSpec.purs b/test/Test/HTTPure/ResponseSpec.purs index 0349fd1..6237245 100644 --- a/test/Test/HTTPure/ResponseSpec.purs +++ b/test/Test/HTTPure/ResponseSpec.purs @@ -45,9 +45,11 @@ sendSpec = \response -> Aff.makeAff \done -> do stream <- pure $ HTTP.responseAsStream response - _ <- Stream.writeString stream Encoding.UTF8 "test" $ pure unit - _ <- Stream.end stream $ pure unit - done $ Either.Right unit + void + $ Stream.writeString stream Encoding.UTF8 "test" + $ Stream.end stream + $ done + $ Either.Right unit pure Aff.nonCanceler } diff --git a/test/Test/HTTPure/TestHelpers.js b/test/Test/HTTPure/TestHelpers.js index bd78422..a97929d 100644 --- a/test/Test/HTTPure/TestHelpers.js +++ b/test/Test/HTTPure/TestHelpers.js @@ -30,11 +30,19 @@ exports.mockResponse = function() { body: "", headers: {}, - write: function(str) { + write: function(str, encoding, callback) { this.body = this.body + str; + if (callback) { + callback(); + } + }, + + end: function(str, encoding, callback) { + if (callback) { + callback(); + } }, - end: function() { }, on: function() { }, once: function() { }, emit: function() { }, diff --git a/test/Test/HTTPure/TestHelpers.purs b/test/Test/HTTPure/TestHelpers.purs index cb23e54..09ccec1 100644 --- a/test/Test/HTTPure/TestHelpers.purs +++ b/test/Test/HTTPure/TestHelpers.purs @@ -47,8 +47,10 @@ request secure port method headers path body = req <- HTTPClient.request options $ Either.Right >>> done let stream = HTTPClient.requestAsStream req - _ <- Stream.writeString stream Encoding.UTF8 body $ pure unit - Stream.end stream $ pure unit + void + $ Stream.writeString stream Encoding.UTF8 body + $ Stream.end stream + $ pure unit pure Aff.nonCanceler where options =