Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /data/e/7/e76990b9-3372-4d88-8089-fce36e16744a/webperfection.net/sub/rady-nosu/wp-content/plugins/seo-ultimate/modules/class.su-module.php on line 1195
Http Basic Authorization Header

August 25, 2012 | In: Programovanie

http basic authorization header

header for http basic authentication

potrebujeme base64encoded user/heslo, na linuxe s php:

php -r "print base64_encode('user:password');"
dXNlcjpwYXNzd29yZA==

v opere ctrl+i tab network, tab make request:
url:
https://example.com/?page=somepage

to co je hrube je nase user/helso

GET /?page=somepage HTTPS/1.1
Host: example.com
Authorization: Basic dXNlcjpwYXNzd29yZA==

response:

HTTP/1.1 200 OK
Date: Sat, 25 Aug 2012 14:58:29 GMT
Server: Apache
X-Powered-By: PHP/5.3.3-7+squeeze13
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

v spojeni s adobe flex

aby sme sa v nasej aplikacke prihlasili na server bez nutnosti okienok tak vyplnime a posleme hlavicku:

import mx.utils.Base64Encoder;
import mx.rpc.http.HTTPService;
private var service:HTTPService

private function authAndSend():void
{
service = new HTTPService();
var encoder:Base64Encoder = new Base64Encoder();
encoder.encode("user:password");
service.headers = {Authorization:"Basic " + encoder.toString()};
service.send();
}

Share This:

Comments are closed.