Open genbattle opened 4 years ago
I see this library also has a Host struct, but I don't see any way to convert a Host into a Url
you would need a scheme to convert it to a valid URL. But it does seem like there should be an API to build a url from parts rather than having to create a string and parse it. Maybe an api that allows you to do something like:
let url = Url::builder("http").host(host).port(port)
I'm using the URL library to parse a Host header
The Host header isn't a URL. It is just the host, optionally followed by the port.
I'm using the URL library to parse a
Host
header, and when my application is running on localhost the value that comes out of the header islocalhost:3000
(for example).This value is parsed into a
Url
but comes out withcannot_be_a_base()
astrue
, so I can't join it.With url
2.1.1
I can't callset_scheme
on the parsed URL either, but that seems to be related to another regression that multiple people have raised in #577. With2.1.0
I can callset_scheme
on the parsed URL but it still comes out ascannot_be_a_base()
.I worked around this by prepending "http://" onto whatever comes out of the
Host
header. I see this library also has aHost
struct, but I don't see any way to convert aHost
into aUrl
. I guess what' I'm looking for is a better way to build a URL from parts.