Skip to content
This repository has been archived by the owner on Jan 16, 2018. It is now read-only.

HttpMethodsClient constructor options #11

Open
dbu opened this issue Oct 23, 2015 · 10 comments
Open

HttpMethodsClient constructor options #11

dbu opened this issue Oct 23, 2015 · 10 comments

Comments

@dbu
Copy link
Contributor

dbu commented Oct 23, 2015

We should have constructor options to control the HttpMethodsClient behaviour

  • default_headers => plugin
  • base_url (domain and start path, to be combined with the send() methods, see also Base URI handling httplug#36)
  • preserve_host (whether to update the default HOST header from the $uri argument if an absolute url is passed, but no explicit HOST header)
@dbu dbu changed the title HttpMethodsClient options HttpMethodsClient constructor options Oct 23, 2015
@joelwurtz
Copy link
Member

Should we not do this in the Plugin and attach the PluginClient to the HttpMethodsClient instead ?

@dbu
Copy link
Contributor Author

dbu commented Oct 29, 2015

i am not sure if a request can be instantiated with a relative path or without domain. if it can, then yes. not sure at which point validation happens, or if PSR-7 says anything about that. if some implementations validate at construction time, we do need something here.

but indeed, what can be done as plugin should really be plugin.

@sagikazarmark
Copy link
Member

attach the PluginClient to the HttpMethodsClient instead

What does attach mean in this context?

Even if there are colliding features in the PluginClient and the MethodsClient, I would say they should not be coupled. With other words things which are necessary to have in the MethodsClient, should be done there.

@dbu
Copy link
Contributor Author

dbu commented Oct 29, 2015

for preserve_host i don't know if this can be done in a plugin. maybe its an option on the default headers plugin to set the HOST from the url.

@sagikazarmark for things plugins can do i agree that we should use a configured PluginClient inside the HttpMethodsClient rather than duplicating logic in HttpMethodsClient.

@sagikazarmark
Copy link
Member

What I am saying: MethodsClient should work on it's own without requiring PluginClient. Otherwise it is hard coupling.

@dbu
Copy link
Contributor Author

dbu commented Oct 29, 2015

i agree. we just should not provide functionality in this client that
plugins can already do.

On 29.10.2015 10:45, Márk Sági-Kazár wrote:

What I am saying: MethodsClient should work on it's own without
requiring PluginClient. Otherwise it is hard coupling.


Reply to this email directly or view it on GitHub
#11 (comment).

Liip AG // Agile Web Development // T +41 43 500 39 80
CH-8005 Zurich // PGP 0xA581808B // www.liip.ch

@joelwurtz
Copy link
Member

i am not sure if a request can be instantiated with a relative path or without domain. if it can, then yes. not sure at which point validation happens, or if PSR-7 says anything about that. if some implementations validate at construction time, we do need something here.

Don't remind that PSR-7 set something about that, if using the socket-client you can have a relative path only in the request which is enough as there may be no host needed (like for a unix socket : unix:///var/run/server.sock)

@sagikazarmark
Copy link
Member

In PSR7 Host is required I think.

@joelwurtz
Copy link
Member

PSR-7 :

During construction, implementations MUST attempt to set the Host header from a provided URI if no Host header is provided.

RequestInterface::withUri() will, by default, replace the returned request's Host header with a Host header matching the host component of the passed UriInterface.

It say "must attempt", so they need to try but doesn't say something when the attempt fail

And their examples show case when the host header is empty, so it is not required and can be empty

@sagikazarmark
Copy link
Member

Ah, ok. Thanks for clarifing that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants