Giter Club home page Giter Club logo

Comments (6)

gggeek avatar gggeek commented on June 2, 2024 1

As a side note: besides the timeout there are many more options that can affect the http calls made: usage of ssl certs and proxies being the first two that come to mind.

I think that an ideal API would be the following:

  • allow those to be set per-request
  • allow those to be set per-client
  • the per-request settings would override the per-client settings

This would cover both the case of 'use same settings for every call' as well as the case 'use a specific setting only for one call'

Alas I don't see how this would be doable without altering teh PSR-7 interfaces (or at least subclassing them in httplug interfaces)

from httplug.

zerkms avatar zerkms commented on June 2, 2024 1

its not the job of your business code to know about such shortcomings of the network infrastructure

it's not*, but it's still part of the business logic: some applications might be critical to latency hence it would be part of their actual business layer to know how long processes should/may take.

There is even RFC for that: https://www.rfc-editor.org/rfc/rfc7240

from httplug.

dbu avatar dbu commented on June 2, 2024 1

configure timeouts on the http client.

if you need different settings for different use cases, configure different clients for those use cases and inject the correct client to the correct service.

from httplug.

dbu avatar dbu commented on June 2, 2024 1

i don't see the RFC implying that. of course the header is sent with each request as all http headers are.

also, the RFC is about the HTTP protocol, not about how to implement clients.

of course you can do it differently, and i am sure there are valid use cases for this. but if you do something highly specific to HTTP, you will need a specific client implementation (or maybe even raw sockets) to get more control over HTTP.

also be aware that this is the wrong place for this discussion. HTTPlug is only about the async client now. synchronous clients are specified in PSR-18 and the sync client interface in this repository is deprecated. but i don't expect PSR-18 to be changed for dynamic headers either.

from httplug.

dbu avatar dbu commented on June 2, 2024

sorry, i somehow missed this question. i wrote an answer in #132. in short, our philosophy is that your application should not be bound to http. the layer using http clients should use pre-configured http clients for specific cases. another option could be to have a plugin specific to your client (e.g. guzzle 6) that sets the timeout based on the domain or such logic - its not the job of your business code to know about such shortcomings of the network infrastructure...

i will close this to keep the discussion centralized in one place, if further discussion is needed.

from httplug.

zerkms avatar zerkms commented on June 2, 2024

@dbu any chance you checked https://www.rfc-editor.org/rfc/rfc7240#section-4.3 ? It implies timeouts are configured on per-request basis 🤷

from httplug.

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.