headers icon indicating copy to clipboard operation
headers copied to clipboard

implement as_str(), Display for Referer

Open goto-bus-stop opened this issue 4 years ago • 4 comments

So you can get the value out 😇 I just copied the implementation from the UserAgent type.

goto-bus-stop avatar Nov 03 '21 13:11 goto-bus-stop

ok, tests were failing for good reason, i forgot to run them locally first…

goto-bus-stop avatar Nov 03 '21 20:11 goto-bus-stop

Thanks for the PR! 😀

I haven't really thought about this, but curious to hear what you think: is it right to model the Referer as always a UTF-8 string? I guess it's usually going to be a URI, right? And so far in http, we've assumed that needs to be UTF-8...

seanmonstar avatar Nov 03 '21 20:11 seanmonstar

i think it's OK to model it as always a URI … technically you could make a request that has some arbitrary data in there, but i don't think anyone intentionally wants to receive non-URIs in the referer field. browsers would only send a URI.

goto-bus-stop avatar Nov 07 '21 22:11 goto-bus-stop

Actually, that reminds me. If we expose an as_str(), then we can't ever change this header to actually hold an http::Uri, for example, since that splits the string into 3 pieces. What if we just merge an impl Display for now?

seanmonstar avatar Nov 08 '21 19:11 seanmonstar

With #122 merged, I think this should be closed.

jplatte avatar Jan 03 '24 19:01 jplatte

great! 😁

goto-bus-stop avatar Jan 03 '24 19:01 goto-bus-stop