Any examples of using RequestBodyBuilder from http-enumerator

Hi all, I'm a bit stumped on how to use the RequestBodyBuilder constructor: http://hackage.haskell.org/packages/archive/http-enumerator/latest/doc/html/... Is anyone able to point me at some code that uses this? Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

On Fri, Dec 9, 2011 at 5:50 AM, Erik de Castro Lopo
Hi all,
I'm a bit stumped on how to use the RequestBodyBuilder constructor:
http://hackage.haskell.org/packages/archive/http-enumerator/latest/doc/html/...
Is anyone able to point me at some code that uses this?
Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel
No examples, sorry, but the idea is to provide a Builder instead of a ByteString, so that you can cheaply concatenate together smaller pieces and avoid a potentially costly length operation *if* you know the ultimate size of the body. You could consider the following to be equivalent: RequestBodyBS bs ~== RequstBodyBuilder (S.length bs) (fromByteString bs) HTH, Michael

Michael Snoyman wrote:
RequestBodyBS bs ~== RequstBodyBuilder (S.length bs) (fromByteString bs)
Ok, that probably means I need to look at RequestBodyEnum instead. What I'd like to do is somthing like: status <- getFileStatus fname let size = fromIntegral $ fileSize status req { HE.requestBody = HE.RequestBodyEnum size $ enumBuilder fname } where enumBuilder :: String -> Enumerator Builder IO () enumBuilder fname = EB.enumFile fname ........ but I can't get the types to match up. Its seems the () requirement for enumBuilder is too inflexible. Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

I think I had a similar problem once. The () may need to be changed to
forall a. a. Consider filing a bug in http-enumerator.
Aristid
Am 09.12.2011 08:16 schrieb "Erik de Castro Lopo"
Michael Snoyman wrote:
RequestBodyBS bs ~== RequstBodyBuilder (S.length bs) (fromByteString
bs)
Ok, that probably means I need to look at RequestBodyEnum instead.
What I'd like to do is somthing like:
status <- getFileStatus fname let size = fromIntegral $ fileSize status req { HE.requestBody = HE.RequestBodyEnum size $ enumBuilder fname } where enumBuilder :: String -> Enumerator Builder IO () enumBuilder fname = EB.enumFile fname ........
but I can't get the types to match up. Its seems the () requirement for enumBuilder is too inflexible.
Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

Can I see an actual code snippet where this comes up? I'd be surprised
if we need such a change.
On Fri, Dec 9, 2011 at 10:04 AM, Aristid Breitkreuz
I think I had a similar problem once. The () may need to be changed to forall a. a. Consider filing a bug in http-enumerator.
Aristid
Am 09.12.2011 08:16 schrieb "Erik de Castro Lopo"
: Michael Snoyman wrote:
RequestBodyBS bs ~== RequstBodyBuilder (S.length bs) (fromByteString bs)
Ok, that probably means I need to look at RequestBodyEnum instead.
What I'd like to do is somthing like:
status <- getFileStatus fname let size = fromIntegral $ fileSize status req { HE.requestBody = HE.RequestBodyEnum size $ enumBuilder fname } where enumBuilder :: String -> Enumerator Builder IO () enumBuilder fname = EB.enumFile fname ........
but I can't get the types to match up. Its seems the () requirement for enumBuilder is too inflexible.
Cheers, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel
_______________________________________________ web-devel mailing list web-devel@haskell.org http://www.haskell.org/mailman/listinfo/web-devel

Erik de Castro Lopo wrote:
Michael Snoyman wrote:
RequestBodyBS bs ~== RequstBodyBuilder (S.length bs) (fromByteString bs)
Ok, that probably means I need to look at RequestBodyEnum instead.
What I'd like to do is somthing like:
status <- getFileStatus fname let size = fromIntegral $ fileSize status req { HE.requestBody = HE.RequestBodyEnum size $ enumBuilder fname } where enumBuilder :: String -> Enumerator Builder IO () enumBuilder fname = EB.enumFile fname ........
but I can't get the types to match up. Its seems the () requirement for enumBuilder is too inflexible.
Yay! Got it at last: enumBuilder :: String -> Enumerator Builder IO () enumBuilder fname = EB.enumFile fname $= EL.map fromByteString Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
participants (3)
-
Aristid Breitkreuz
-
Erik de Castro Lopo
-
Michael Snoyman