diff options
author | bptato <nincsnevem662@gmail.com> | 2025-01-03 01:15:11 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-01-03 01:15:11 +0100 |
commit | 4fba568b40e6ca0daab90ca2807c4c58b5405697 (patch) | |
tree | 0f2581b9766084600c0da5ecbf1285c8fba28cd0 /src/types | |
parent | 15e1b5369542f5f9bc552922a1014ae35999c729 (diff) | |
download | chawan-4fba568b40e6ca0daab90ca2807c4c58b5405697.tar.gz |
loader: add proper HTTP auth handling
Until now, we just stuffed it into the URL, which was somewhat problematic. Mainstream browsers like to hide the username from the user, but I've decided to follow w3m: buffers do not receive auth info, but the pager itself displays the username. As for the origin: I wanted to use the regular origin, but that does not work with any custom URL. So instead of changing the regular origin function, I've added another.
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/url.nim | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/types/url.nim b/src/types/url.nim index 52aa67c3..0c460bbd 100644 --- a/src/types/url.nim +++ b/src/types/url.nim @@ -1169,6 +1169,17 @@ proc origin*(url: URL): Origin = else: return Origin(t: otOpaque, s: $url) +# This follows somewhat different rules from the standard: +# * with htNone, the origin is opaque. +# * with other host types, the origin is a tuple origin. +proc authOrigin*(url: URL): Origin = + if url.hostType != htNone: + return Origin( + t: otTuple, + tup: (url.scheme, url.hostname, url.port, none(string)) + ) + return Origin(t: otOpaque, s: $url) + proc `==`*(a, b: Origin): bool {.error.} = discard |