From d37096dccee100b3149f3d703a5c6efb1c08310a Mon Sep 17 00:00:00 2001 From: Gareth Smith Date: Wed, 25 Sep 2019 01:09:29 +0100 Subject: [PATCH] Add some type declarations to get compatibility with node-buffer 6.x. (#149) Since node-buffer 6.x is not yet in the package set, compatibility with node-buffer 5.x is maintained. --- bower.json | 2 +- src/HTTPure/Body.purs | 4 +++- test/Test/HTTPure/BodySpec.purs | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index dbd8c65..df987e2 100644 --- a/bower.json +++ b/bower.json @@ -31,7 +31,7 @@ "purescript-lists": "^5.4.0", "purescript-maybe": "^4.0.1", "purescript-newtype": "^3.0.0", - "purescript-node-buffer": "^5.0.0", + "purescript-node-buffer": "^5.0.0 || ^6.0.0", "purescript-node-child-process": "^6.0.0", "purescript-node-fs": "^5.0.0", "purescript-node-fs-aff": "^6.0.0", diff --git a/src/HTTPure/Body.purs b/src/HTTPure/Body.purs index 347e8f1..ac3ca73 100644 --- a/src/HTTPure/Body.purs +++ b/src/HTTPure/Body.purs @@ -39,7 +39,9 @@ class Body b where -- | response stream and closing the response stream. instance bodyString :: Body String where - defaultHeaders body = Buffer.fromString body Encoding.UTF8 >>= defaultHeaders + defaultHeaders body = do + buf :: Buffer.Buffer <- Buffer.fromString body Encoding.UTF8 + defaultHeaders buf write body response = Aff.makeAff \done -> do let stream = HTTP.responseAsStream response diff --git a/test/Test/HTTPure/BodySpec.purs b/test/Test/HTTPure/BodySpec.purs index d92a07a..a30f3dd 100644 --- a/test/Test/HTTPure/BodySpec.purs +++ b/test/Test/HTTPure/BodySpec.purs @@ -33,7 +33,7 @@ defaultHeadersSpec = Spec.describe "defaultHeaders" do headers ?= Headers.header "Content-Length" "3" Spec.describe "Buffer" do Spec.it "has the correct Content-Length header" do - buf <- EffectClass.liftEffect $ Buffer.fromString "foobar" Encoding.UTF8 + buf :: Buffer.Buffer <- EffectClass.liftEffect $ Buffer.fromString "foobar" Encoding.UTF8 headers <- EffectClass.liftEffect $ Body.defaultHeaders buf headers ?= Headers.header "Content-Length" "6" Spec.describe "Readable" do @@ -55,7 +55,7 @@ writeSpec = Spec.describe "write" do Spec.it "writes the Buffer to the Response body" do body <- do resp <- EffectClass.liftEffect TestHelpers.mockResponse - buf <- EffectClass.liftEffect $ Buffer.fromString "test" Encoding.UTF8 + buf :: Buffer.Buffer <- EffectClass.liftEffect $ Buffer.fromString "test" Encoding.UTF8 Body.write buf resp pure $ TestHelpers.getResponseBody resp body ?= "test"