git.iko.soy/rowtype-yoga/purescript-fetch
on main help sign in
Add duplex: half to stream bodies
commitb6ef8440486ba3dcd0f03ab1b6c286353e064f0c authorThomas Honeyman <hello@thomashoneyman.com> dateMon 7 Aug 2023, 19:37 (3 years ago) parent7fbaf4c
5 files changed+11−2
bower.json+1−1 packages.dhall+2 src/Fetch/Internal/Request.purs+6 test.dhall−1 test/Test/FetchSpec.purs+2
bower.json+1−1
@@ -10,7 +10,7 @@
1010 "purescript-aff": "^v7.0.0",
1111 "purescript-arraybuffer-types": "^v3.0.2",
1212 "purescript-effect": "^v4.0.0",
13− "purescript-fetch-core": "https://github.com/rowtype-yoga/purescript-fetch-core.git#^5.0.0",
13+ "purescript-fetch-core": "https://github.com/rowtype-yoga/purescript-fetch-core.git#^5.1.0",
1414 "purescript-foreign": "^v7.0.0",
1515 "purescript-http-methods": "^v6.0.0",
1616 "purescript-js-promise-aff": "https://github.com/purescript-contrib/purescript-js-promise-aff.git#^v1.0.0",
packages.dhall+2
@@ -3,3 +3,5 @@ let upstream =
33 sha256:0c2cf73e053ddace5094ba6c0ef3077f98b7ce76b822a51af66b6bba30cddaf5
44
55in upstream
6+ with
7+ fetch-core.version = "v5.1.0"
src/Fetch/Internal/Request.purs+6
@@ -16,6 +16,9 @@ import Data.Newtype (un)
1616import Data.Symbol (class IsSymbol)
1717import Effect (Effect)
1818import Effect.Uncurried (runEffectFn2)
19+import Fetch.Core.Duplex (Duplex)
20+import Fetch.Core.Duplex as CoreDuplex
21+import Fetch.Core.Duplex as Duplex
1922import Fetch.Core.Headers (Headers)
2023import Fetch.Core.Headers as CoreHeaders
2124import Fetch.Core.Integrity (Integrity(..))
@@ -56,6 +59,7 @@ type HighlevelRequestOptions headers body =
5659 , referrer :: CoreReferrer.Referrer
5760 , referrerPolicy :: CoreReferrerPolicy.ReferrerPolicy
5861 , integrity :: CoreIntegrity.Integrity
62+ , duplex :: CoreDuplex.Duplex
5963 )
6064
6165new
@@ -128,3 +132,5 @@ instance ToCoreRequestOptionsConverter "referrerPolicy" ReferrerPolicy String wh
128132instance ToCoreRequestOptionsConverter "integrity" Integrity String where
129133 convertImpl _ = un Integrity
130134
135+instance ToCoreRequestOptionsConverter "duplex" Duplex String where
136+ convertImpl _ = Duplex.toString
test.dhall−1
@@ -9,6 +9,5 @@ in conf
99 , "spec"
1010 , "spec-discovery"
1111 , "strings"
12− , "debug"
1312 ]
1413 }
test/Test/FetchSpec.purs+2
@@ -6,6 +6,7 @@ import Data.ArrayBuffer.Types (Uint8Array)
66import Data.Maybe (Maybe(..))
77import Fetch (Method(..), Referrer(..), RequestMode(..), fetch, fetchBody)
88import Fetch as Fetch
9+import Fetch.Core.Duplex (Duplex(..))
910import Foreign (unsafeFromForeign)
1011import Test.Spec (Spec, describe, it)
1112import Test.Spec.Assertions (shouldEqual)
@@ -47,6 +48,7 @@ spec =
4748 , body: helloWorldStream
4849 , headers: { "Content-Type": "application/json" }
4950 , referrer: (ReferrerUrl "https://httpbin.org")
51+ , duplex: Half
5052 }
5153 { json: j } <- json <#> unsafeFromForeign
5254 j `shouldEqual` { hello: "world" }