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:HTTPServiceprivate function authAndSend():void
{
service = new HTTPService();
var encoder:Base64Encoder = new Base64Encoder();
encoder.encode("user:password");
service.headers = {Authorization:"Basic " + encoder.toString()};
service.send();
}
Comments are closed.