Git Product home page Git Product logo

Comments (7)

SchlenkR avatar SchlenkR commented on May 24, 2024 1

Yes, definitely. I have to check how cancellation is done in the underlying HttpClient and others and then decide how the API should allow passing tokens, etc.

from fshttp.

jcmrva avatar jcmrva commented on May 24, 2024 1

I'd be happy with either one, but having a choice is great. Thanks for getting this in!

from fshttp.

SchlenkR avatar SchlenkR commented on May 24, 2024 1

Hi Josh. I just released v12 (https://www.nuget.org/packages/FsHttp). Could you check please if it all works for you? Thank you.

from fshttp.

SchlenkR avatar SchlenkR commented on May 24, 2024

Hint:

grafik

from fshttp.

SchlenkR avatar SchlenkR commented on May 24, 2024

527e9b6
99e5f26

from fshttp.

SchlenkR avatar SchlenkR commented on May 24, 2024

For clarification + documentation:
There are 2 solutions that seems to be reaonable for an implementation:

  • Setting the cancellation token on "define-time" (as part of the request)
  • Passing it along at "execution-time" (something like http { GET "url" } |> Request.withCancellationToken tok |> Request.sendAsync).

The 2nd approach seems to me like the way to go, because: A FsHttp request is just data, out of which a dotnet HttpRequest is constructed and executed. This can happen multiple times. But: This is not strictly followed through since it's (for example) possible to capture an instance of HttpClient via an HttpClientTransformer, which is then part of the FsHttp request. I can also think of scenarios where it's wanted to bind a CTok to a request definition. This automatically also provides the possibility for passing a CTok ad-hoc on execution time, like shown above.

There are now these 2 possibilities implemented:

// It is possible to bind a cancellation token to a request definition,
// that will be used for the underlying HTTP request:

use cts = new CancellationTokenSource()

// ...

http {
    GET "https://mysite"
    config_cancellationToken cts.Token
}
|> Request.send


// See also: https://github.com/fsprojects/FsHttp/issues/105

// Instead of binding a cancellation token directly to a request definition (like in the example above),
// it is also possible to pass it on execution-timer, like so:

http {
    GET "https://mysite"
}
|> Config.cancellationToken cts.Token
|> Request.send

from fshttp.

jcmrva avatar jcmrva commented on May 24, 2024

Do you have an estimate for when the next Nuget package will be released?

from fshttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.