Skip to content

readString returns Nothing, but pipe shows data #12

@kobble-git

Description

@kobble-git

I'm having a curious problem when I use Node.HTTP.Client. When I try to use readString on the response, I get Nothing but if I pipe the responseStream to stdout (for instance), I can see the data. Specifically, I am using Node.HTTP.Client to get an access_code from a github oauth2 flow.

I'm posting this here because it looks like a stream issue, and to look for any guidance as to what I could look for.

Here is the code:

affRequest :: forall eff. Options RequestOptions -> (Request -> Eff (err :: EXCEPTION, console :: CONSOLE, http :: HTTP | eff) Unit) -> Aff (err :: EXCEPTION, console :: CONSOLE, http :: HTTP | eff) (Maybe String)
affRequest opts f = makeAff \_ cb -> do
    req <- request opts \res -> do
          let responseStream = responseAsStream res
          mc <- readString responseStream Nothing UTF8
          pipe responseStream stdout
          cb mc

mc is Nothing, but I can see the correct data (the access_code) on stdout.

Cheers.

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