Comments (17)
I am planning to add this feature to the adapter client since there you pass URIs directly to the client. In other adapters it is the developers responsibility to fill the request with valid data. That said, I can imagine a BaseUriSubscriber.
from httplug.
would this have to be a plugin? can the client interact with plugins? or would the idea be to have a plugin that completes incomplete urls with a base uri? or can Request objects not be created with incomplete urls?
from httplug.
- Not have to, but we discussed here why it would be better.
- Nope, plugins should be transparent
- Yup
- Not sure, have to check.
from httplug.
if they need to be complete, the base url would make sense in the HttpMethodsClient in the utils.
from httplug.
Agreed. Since HttpMethodsClient is an implementation, we can declare howit should be configured. Options array in constructor with base URL option?
from httplug.
And should this populate the Host header of the request if not set ?
from httplug.
from httplug.
And should this populate the Host header of the request if not set ?
base_url should start with protocol and host name imo. you can't send a
request to just a path.
Not sure how this answers the original question. AFAIK Host header is not mandatory. I think you can send a request to just a path, if the Host header is populated.
from httplug.
from httplug.
i would assume that populating the host header from an absolute url is also job of the message factory,
I disagree. Message Factory should only create the request, but shouldn't validate the input (only the number and format of input parameters).
Actually the client shouldn't validate as well: if someone inputs invalid data and the request fails, an exception should be thrown.
Actually PSR7 has a specification for this header:
https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md#host-header
from httplug.
from httplug.
Keep in mind, that the interface itself should not care about this. The MethodsClient implementation can. I would say only those adapters should care about this where we know that the underlying client does not.
from httplug.
from httplug.
In fact Host header is mandatory for 1.1 Protocol but not for 1.0 (i.e. sending a request with 1.1 protocol without the Host header to nginx will result in a 400 bad request)
So maybe this "Plugin" should also throw an Exception if Protocol is 1.1 and attempt to set the Host header fails ?
from httplug.
created php-http/utils#11
the rest would now be a topic for the plugins. though i am not sure if the message factory does not take care of that already. might be implementation specific whether the Request instance accepts to be created with incomplete data or not.
from httplug.
Request being incomplete depends on the point of view. For example as @joelwurtz pointed, HTTP 1.1 requires the Host header, 1.0 does not.
from httplug.
added note to #37
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
- How to set timeout for a request while being abstracted from a HttpClient implementation? HOT 6
- 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.