Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/request.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ let make ?(meth=`GET) ?(version=`HTTP_1_1) ?encoding ?headers uri =
match headers with
| None -> Header.init ()
| Some h -> h in
let headers =
(* Add user:password auth to headers from uri
* if headers don't already have auth *)
match Header.get_authorization headers, Uri.userinfo uri with
| None, Some userinfo -> begin
match Stringext.split ~on:':' userinfo ~max:2 with
| [user; pass] ->
let auth = `Basic (Uri.pct_decode user, Uri.pct_decode pass) in
Header.add_authorization headers auth
| _ -> headers
end
| _, _ -> headers
in
let encoding =
match encoding with
| None -> begin
Expand Down