Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

README corrections #159

Copy link
Copy link
@rm2

Description

@rm2
Issue body actions

The README currently states:

2 - The Http response (or just the response code/body) is retrieved using one of the following:

job {
  use! response = getResponse request // disposed at the end of async, don't
                                      // fetch outside async body
  // the above doesn't download the response, so you'll have to do that:
  let! bodyStr = Response.readBodyAsString response
  // OR:
  //let! bodyBs = Response.readBodyAsBytes

  // remember HttpFs doesn't buffer the stream (how would we know if we're
  // downloading 3GiB?), so once you use one of the above methods, you can't do it
  // again, but have to buffer/stash it yourself somewhere.
  return bodyStr
}

IMO it should really say:

2 - The Http response (or just the response code/body) is retrieved using one of the following:

job {
use! response = getResponse request // disposed at the end of Hopac job, don't
// fetch outside Hopac job body
// while the above does download the full response, it doesn't give you access to the body content. You'll have to do this:
let! bodyStr = Response.readBodyAsString response
// OR:
//let! bodyBs = Response.readBodyAsBytes

// remember HttpFs doesn't buffer the stream (how would we know if we're
// downloading 3GiB?), so once you use one of the above methods, you can't do it
// again, but have to buffer/stash it yourself somewhere.
return bodyStr
}

as demonstrated by issue #158, wherein I got the full response even though I didn't think I was asking for it. And perhaps even say (the more examples of using Hopac with HttpFs in various situations the better), to be explicit:

If for some reason, you only want to get the headers, instead do:

let statusCode, contentType, headers =
  Hopac.Hopac.job {
    use! response = HttpFs.Client.getEventSourceResponse request
    let statusCode = response.statusCode
    let contentType = response.headers.[HttpFs.Client.ResponseHeader.ContentTypeResponse]
   return statusCode, contentType, response.headers
  } |> Hopac.Hopac.run
haf and MarneeDear

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.