Merge pull request #109 from hendrikcech/getResponseHeader

client.authenticate in browser with browserify
This commit is contained in:
Eran Hammer 2014-03-29 12:03:31 -07:00
Родитель 9d42e96977 4c4523ba04
Коммит 866651fb3f
1 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -154,11 +154,13 @@ hawk.client = {
options = options || {};
if (request.getResponseHeader('www-authenticate')) {
var getResponseHeader = (request.getResponseHeader || request.getHeader).bind(request);
if (getResponseHeader('www-authenticate')) {
// Parse HTTP WWW-Authenticate header
var attributes = hawk.utils.parseAuthorizationHeader(request.getResponseHeader('www-authenticate'), ['ts', 'tsm', 'error']);
var attributes = hawk.utils.parseAuthorizationHeader(getResponseHeader('www-authenticate'), ['ts', 'tsm', 'error']);
if (!attributes) {
return false;
}
@ -175,13 +177,13 @@ hawk.client = {
// Parse HTTP Server-Authorization header
if (!request.getResponseHeader('server-authorization') &&
if (!getResponseHeader('server-authorization') &&
!options.required) {
return true;
}
var attributes = hawk.utils.parseAuthorizationHeader(request.getResponseHeader('server-authorization'), ['mac', 'ext', 'hash']);
var attributes = hawk.utils.parseAuthorizationHeader(getResponseHeader('server-authorization'), ['mac', 'ext', 'hash']);
if (!attributes) {
return false;
}
@ -212,7 +214,7 @@ hawk.client = {
return false;
}
var calculatedHash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, request.getResponseHeader('content-type'));
var calculatedHash = hawk.crypto.calculatePayloadHash(options.payload, credentials.algorithm, getResponseHeader('content-type'));
return (calculatedHash === attributes.hash);
},