Giter VIP home page Giter VIP logo

Comments (17)

sagikazarmark avatar sagikazarmark commented on May 21, 2024

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.

dbu avatar dbu commented on May 21, 2024

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.

sagikazarmark avatar sagikazarmark commented on May 21, 2024
  1. Not have to, but we discussed here why it would be better.
  2. Nope, plugins should be transparent
  3. Yup
  4. Not sure, have to check.

from httplug.

dbu avatar dbu commented on May 21, 2024

if they need to be complete, the base url would make sense in the HttpMethodsClient in the utils.

from httplug.

sagikazarmark avatar sagikazarmark commented on May 21, 2024

Agreed. Since HttpMethodsClient is an implementation, we can declare howit should be configured. Options array in constructor with base URL option?

from httplug.

joelwurtz avatar joelwurtz commented on May 21, 2024

And should this populate the Host header of the request if not set ?

from httplug.

dbu avatar dbu commented on May 21, 2024

from httplug.

sagikazarmark avatar sagikazarmark commented on May 21, 2024

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.

dbu avatar dbu commented on May 21, 2024

from httplug.

sagikazarmark avatar sagikazarmark commented on May 21, 2024

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.

dbu avatar dbu commented on May 21, 2024

from httplug.

sagikazarmark avatar sagikazarmark commented on May 21, 2024

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.

dbu avatar dbu commented on May 21, 2024

from httplug.

joelwurtz avatar joelwurtz commented on May 21, 2024

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.

dbu avatar dbu commented on May 21, 2024

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.

sagikazarmark avatar sagikazarmark commented on May 21, 2024

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.

dbu avatar dbu commented on May 21, 2024

added note to #37

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.