Skip to content
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

Add some type declarations to get compatibility with node-buffer 6.x. #149

Merged
merged 1 commit into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
Add some type declarations to get compatibility with node-buffer 6.x.
Since node-buffer 6.x is not yet in the package set, compatibility with
node-buffer 5.x is maintained.
  • Loading branch information
Dretch committed Sep 24, 2019
commit cee84fa4549416deef735d18647d4b69ca0c8992
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/HTTPure/Body.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/Test/HTTPure/BodySpec.purs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down