[erlang-patches] patch to allow empty passwords in http client basic authorization

Tim Fletcher twoggle@REDACTED
Tue May 5 12:04:19 CEST 2009


Use case: some web services use basic auth, with a token as the user
part and no password part.

Curl has support for this.


--- httpc_request.erl	2009-03-12 12:31:41.000000000 +0000
+++ httpc_request.patched.erl	2009-05-05 10:45:00.000000000 +0100
@@ -201,6 +201,9 @@
 	[User, Passwd] ->
 	    UserPasswd = base64:encode_to_string(User ++ ":" ++ Passwd),
 	    Headers#http_request_h{authorization = "Basic " ++ UserPasswd};
+	[User] ->
+	    UserPasswd = base64:encode_to_string(User ++ ":"),
+	    Headers#http_request_h{authorization = "Basic " ++ UserPasswd};
 	_ ->
 	    Headers
     end.



More information about the erlang-patches mailing list