docs(headers): document the fact that <Basic as FromStr>::from_str takes a base-64 encoded string

I couldn't figure out why my "username:password" strings kept failing to parse
into a Basic auth header, until I realized that the implementation expects
it to be base-64 encoded, which would be the case if it was coming from HTTP.
I'm not sure if this is the best place to document it, but hopefully it will
make it more clear for other people / me when I forget.

Perhaps a better approach would be to document somewhere that all `FromStr` impls for
headers are there for parsing request headers, and not really for creating them.
This commit is contained in:
Michael Hewson
2018-02-19 23:56:55 -05:00
parent 77adab4ebf
commit ba6fcf33b0

View File

@@ -167,6 +167,7 @@ impl Scheme for Basic {
} }
} }
/// creates a Basic from a base-64 encoded, `:`-delimited utf-8 string
impl FromStr for Basic { impl FromStr for Basic {
type Err = ::Error; type Err = ::Error;
fn from_str(s: &str) -> ::Result<Basic> { fn from_str(s: &str) -> ::Result<Basic> {