Comments (6)
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.
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.
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.
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.
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.
@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)
- HttpFulfilledPromise constructor parameter should be mixed HOT 3
- Circuit Breaker HOT 6
- Missing badges HOT 2
- Sending file from a multipart stream HOT 13
- Add support for HTTP proxies and SSL Client certificates? HOT 7
- Implementation Question: how to code Client options in a library-agnostic way? HOT 5
- Benchmarks? HOT 2
- Prepare version 2.0 HOT 6
- HMAC Authentication Plugin HOT 4
- phpstan complains about Http\Client\Exception HOT 6
- Adding deprecated HOT 5
- HttpException create method self vs static HOT 1
- Symfony HTTP Client Adapter HOT 1
- PSR-18: Network / Request exception inheritance HOT 1
- Add psr-18 github tag HOT 1
- Throwable not supported HOT 8
- State of async HTTP clients and promises HOT 13
- PHP 8.0 support HOT 1
- "php-http/httplug" package is not installed HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httplug.