Skip to content

Support non-UTF8 requests #11

Open

Description

@owickstrom

The String instance of readBody in the Node server assumes UTF8, it should check Content-Type header.

Activity

  1. no-longer-on-githu-b commented on May 15, 2017

    @no-longer-on-githu-b
    Contributor

    It should also support binary data, and streaming, and MIME in general. I think the fundep on ReadableBody needs to be removed for this.

  2. owickstrom commented on May 16, 2017

    @owickstrom
    CollaboratorAuthor

    @rightfold Agreed. Not sure where you mean the functional dependency is, though?

  3. no-longer-on-githu-b commented on May 16, 2017

    @no-longer-on-githu-b
    Contributor

    Fundep from body reader type to body type.

    class ReadableBody req m b | req -> b
  4. owickstrom commented on May 17, 2017

    @owickstrom
    CollaboratorAuthor

    Yes, you're absolutely right. I'll try loosening that, and adding some more instances.

    Regarding binary, I could add an instance for getting an Aff e Buffer, as with String.

    For streaming, exposing the request's Stream will do for now. In the spirit of Hyper, the stream should only be allowed to be read once (it cannot be read twice, but you could get a compile-time error if you try). That would probably require some other design than just handing back the Readable stream -- like hiding the streaming within the indexed monad and track whether you've been streaming or not. Any thoughts?

  5. no-longer-on-githu-b commented on May 17, 2017

    @no-longer-on-githu-b
    Contributor

    Well, where "read once" means "read until exhausted." Stream has a godforsaken Node.js-style callback API, so you can't really demand to read it twice, right? It'll just stop calling you when there's nothing to read.

  6. owickstrom commented on May 18, 2017

    @owickstrom
    CollaboratorAuthor

    Regarding this issue, it should only be about the String instance checking the Content-Type header and using that when doing toString on the buffer. Buffers in general, and streaming, are separate issues, but we already have the PRs open. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions