Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion core-ajax.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@homepage github.io
-->
<link rel="import" href="core-xhr.html">
<polymer-element name="core-ajax" hidden attributes="url handleAs auto params response error method headers body contentType withCredentials progress loading">
<polymer-element name="core-ajax" hidden attributes="url handleAs auto params response error method headers body contentType withCredentials basicUser basicPassword progress loading">
<script>

Polymer('core-ajax', {
Expand Down Expand Up @@ -204,6 +204,24 @@
*/
withCredentials: false,

/**
* User name for basic authorization
*
* @attribute basicUser
* @type string
* @default null
*/
basicUser: null,

/**
* Password for basic authorization
*
* @attribute basicPassword
* @type string
* @default null
*/
basicPassword: null,

/**
* Additional properties to send to core-xhr.
*
Expand Down Expand Up @@ -389,6 +407,10 @@
args.responseType = this.handleAs;
}
args.withCredentials = this.withCredentials;
if (this.basicUser || this.basicPassword) {
args.headers['Authorization'] = 'Basic ' + btoa((this.basicUser || '') + ':' +
(this.basicPassword || ''));
}
args.callback = this.receive.bind(this);
args.url = this.url;
args.method = this.method;
Expand Down