Reputation: 77
I have tried the GET and POST Methods I've looked at tons of resources, but still can't figure out the HTTP command to send passwords and usernames to a server to get authenticated. I know I've asked a similar question, and got RFC 2016 as the answer. But it still need more help. Here is my HTTP message, I'm sending right now...
string m = "POST " + URI " / " + "HTTP/1.1" + "\n" +
"Host:" + Cite + "\n" +
"Authorization:" + " " + "Basic" + " " + username + ":" + password;
Oh and does anybody know the response message if the password is incorrect, I think it looks something like the following, but I'm really unsure.
HTTP/1.1 401 Logon Failed
Upvotes: 0
Views: 116
Reputation: 65274
You are quite close: The concatenation of username, ":" and password must be encoded in base64 before putting it into the header. For example to login "user" with password "pass" you would send
Authorization: Basic dXNlcjpwYXNzCg==
Edit:
The response will always look like
HTTP/v.v NNN some text
with v.v
being the HTTP version actually used (a.o.t. requested, though mostly the same), NNN
being the result code and some text
being a textual representation of the result code.
While the result code (e.g. 401 for unauthorized) is constant, the textual representation is only informational and might be different on various systems.
Upvotes: 2