cactoos-http
cactoos-http copied to clipboard
Auto-detect host wire
It's not very convenient to write a host two times (first in wire, second in request):
final Wire wire = new HtWire("http://www.google.com");
new HtResponse(
wire,
"http://www.google.com", // same string
"GET / HTTP/1.1"
)
I think a wire should be able to read host value from request Host
header:
new HtResponse(
new HtWire(),
"http://www.google.com",
"GET / HTTP/1.1"
)
@yegor256/z please, pay attention to this issue
@g4s8/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!
@g4s8 we can make something like HtAutoHostedWire
, which will add Host
HTTP header automatically if it is not present in the request. Make sense?
@yegor256 would HtAutoHostedWire
be part of the public API?
@llorllale why not?
@yegor256 ok, agreed, Host
may not necessarily match with the physical host that the wire is connected to
Refs:
- https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23
- https://stackoverflow.com/a/43156094/1623885
@0crat in
@g4s8 I think the solution for this problem should be reversed: it should be a request that inserts that header, not a Wire
. The reason is that a "wire" is supposed to be a dumb pipe - it should not be inspecting the contents being sent through it. So I believe the direction currently being pushed for in #21 points to a better solution.
It is very common for the Host
header to have the same value as the URL's host, so I also believe this behavior should be our default.
@llorllale if I understand correctly, Wire
should be created with host
param, right? But if not, I agree that it can be reversed.
The job #19 assigned to @marceloamadeu/z, here is why; the budget is 30 minutes, see §4; please, read §8 and §9; if the task is not clear, read this and this; there will be no monetary reward for this job
The job #19 assigned to @iprogrammerr/z, here is why; the budget is 30 minutes, see §4; please, read §8 and §9; if the task is not clear, read this and this; there will be no monetary reward for this job
@llorllale Right now, it could not be reversed. Wire encapsulates host and port. How it coulde be done? Send method has one argument which is a input. I do not think that reading first line and parsing it according to http rules is a good idea.
@Iprogrammerr I agree
As I said in https://github.com/yegor256/cactoos-http/issues/19#issuecomment-391007559, the Host
header can have a completely different value than the wire's target, and it should be supplied by the user. For all we know, the wire's target could even be an IP address.
I agree that it's an inconvenience (btw - the first example in https://github.com/yegor256/cactoos-http/issues/19#issue-311355752 contains an error: the Host
field's value should not include the URI scheme, so it's not an exact duplicate of the same string), but with no workable design thus far, I'm taking this one out of scope.
@0crat refuse
@0crat refuse (here)
@llorllale The user @iprogrammerr/z resigned from #19, please stop working. Reason for job resignation: Order was cancelled
@0crat out