123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362 |
- goog.provide('goog.net.XhrIo');
- goog.provide('goog.net.XhrIo.ResponseType');
- goog.require('goog.Timer');
- goog.require('goog.array');
- goog.require('goog.asserts');
- goog.require('goog.debug.entryPointRegistry');
- goog.require('goog.events.EventTarget');
- goog.require('goog.json');
- goog.require('goog.log');
- goog.require('goog.net.ErrorCode');
- goog.require('goog.net.EventType');
- goog.require('goog.net.HttpStatus');
- goog.require('goog.net.XmlHttp');
- goog.require('goog.string');
- goog.require('goog.structs');
- goog.require('goog.structs.Map');
- goog.require('goog.uri.utils');
- goog.require('goog.userAgent');
- goog.forwardDeclare('goog.Uri');
- goog.net.XhrIo = function(opt_xmlHttpFactory) {
- goog.net.XhrIo.base(this, 'constructor');
-
- this.headers = new goog.structs.Map();
-
- this.xmlHttpFactory_ = opt_xmlHttpFactory || null;
-
- this.active_ = false;
-
- this.xhr_ = null;
-
- this.xhrOptions_ = null;
-
- this.lastUri_ = '';
-
- this.lastMethod_ = '';
-
- this.lastErrorCode_ = goog.net.ErrorCode.NO_ERROR;
-
- this.lastError_ = '';
-
- this.errorDispatched_ = false;
-
- this.inSend_ = false;
-
- this.inOpen_ = false;
-
- this.inAbort_ = false;
-
- this.timeoutInterval_ = 0;
-
- this.timeoutId_ = null;
-
- this.responseType_ = goog.net.XhrIo.ResponseType.DEFAULT;
-
- this.withCredentials_ = false;
-
- this.progressEventsEnabled_ = false;
-
- this.useXhr2Timeout_ = false;
- };
- goog.inherits(goog.net.XhrIo, goog.events.EventTarget);
- goog.net.XhrIo.ResponseType = {
- DEFAULT: '',
- TEXT: 'text',
- DOCUMENT: 'document',
-
- BLOB: 'blob',
- ARRAY_BUFFER: 'arraybuffer'
- };
- goog.net.XhrIo.prototype.logger_ = goog.log.getLogger('goog.net.XhrIo');
- goog.net.XhrIo.CONTENT_TYPE_HEADER = 'Content-Type';
- goog.net.XhrIo.CONTENT_TRANSFER_ENCODING = 'Content-Transfer-Encoding';
- goog.net.XhrIo.HTTP_SCHEME_PATTERN = /^https?$/i;
- goog.net.XhrIo.METHODS_WITH_FORM_DATA = ['POST', 'PUT'];
- goog.net.XhrIo.FORM_CONTENT_TYPE =
- 'application/x-www-form-urlencoded;charset=utf-8';
- goog.net.XhrIo.XHR2_TIMEOUT_ = 'timeout';
- goog.net.XhrIo.XHR2_ON_TIMEOUT_ = 'ontimeout';
- goog.net.XhrIo.sendInstances_ = [];
- goog.net.XhrIo.send = function(
- url, opt_callback, opt_method, opt_content, opt_headers,
- opt_timeoutInterval, opt_withCredentials) {
- var x = new goog.net.XhrIo();
- goog.net.XhrIo.sendInstances_.push(x);
- if (opt_callback) {
- x.listen(goog.net.EventType.COMPLETE, opt_callback);
- }
- x.listenOnce(goog.net.EventType.READY, x.cleanupSend_);
- if (opt_timeoutInterval) {
- x.setTimeoutInterval(opt_timeoutInterval);
- }
- if (opt_withCredentials) {
- x.setWithCredentials(opt_withCredentials);
- }
- x.send(url, opt_method, opt_content, opt_headers);
- return x;
- };
- goog.net.XhrIo.cleanup = function() {
- var instances = goog.net.XhrIo.sendInstances_;
- while (instances.length) {
- instances.pop().dispose();
- }
- };
- goog.net.XhrIo.protectEntryPoints = function(errorHandler) {
- goog.net.XhrIo.prototype.onReadyStateChangeEntryPoint_ =
- errorHandler.protectEntryPoint(
- goog.net.XhrIo.prototype.onReadyStateChangeEntryPoint_);
- };
- goog.net.XhrIo.prototype.cleanupSend_ = function() {
- this.dispose();
- goog.array.remove(goog.net.XhrIo.sendInstances_, this);
- };
- goog.net.XhrIo.prototype.getTimeoutInterval = function() {
- return this.timeoutInterval_;
- };
- goog.net.XhrIo.prototype.setTimeoutInterval = function(ms) {
- this.timeoutInterval_ = Math.max(0, ms);
- };
- goog.net.XhrIo.prototype.setResponseType = function(type) {
- this.responseType_ = type;
- };
- goog.net.XhrIo.prototype.getResponseType = function() {
- return this.responseType_;
- };
- goog.net.XhrIo.prototype.setWithCredentials = function(withCredentials) {
- this.withCredentials_ = withCredentials;
- };
- goog.net.XhrIo.prototype.getWithCredentials = function() {
- return this.withCredentials_;
- };
- goog.net.XhrIo.prototype.setProgressEventsEnabled = function(enabled) {
- this.progressEventsEnabled_ = enabled;
- };
- goog.net.XhrIo.prototype.getProgressEventsEnabled = function() {
- return this.progressEventsEnabled_;
- };
- goog.net.XhrIo.prototype.send = function(
- url, opt_method, opt_content, opt_headers) {
- if (this.xhr_) {
- throw Error(
- '[goog.net.XhrIo] Object is active with another request=' +
- this.lastUri_ + '; newUri=' + url);
- }
- var method = opt_method ? opt_method.toUpperCase() : 'GET';
- this.lastUri_ = url;
- this.lastError_ = '';
- this.lastErrorCode_ = goog.net.ErrorCode.NO_ERROR;
- this.lastMethod_ = method;
- this.errorDispatched_ = false;
- this.active_ = true;
-
- this.xhr_ = this.createXhr();
- this.xhrOptions_ = this.xmlHttpFactory_ ? this.xmlHttpFactory_.getOptions() :
- goog.net.XmlHttp.getOptions();
-
- this.xhr_.onreadystatechange = goog.bind(this.onReadyStateChange_, this);
-
- if (this.getProgressEventsEnabled() && 'onprogress' in this.xhr_) {
- this.xhr_.onprogress =
- goog.bind(function(e) { this.onProgressHandler_(e, true); }, this);
- if (this.xhr_.upload) {
- this.xhr_.upload.onprogress = goog.bind(this.onProgressHandler_, this);
- }
- }
-
- try {
- goog.log.fine(this.logger_, this.formatMsg_('Opening Xhr'));
- this.inOpen_ = true;
- this.xhr_.open(method, String(url), true);
- this.inOpen_ = false;
- } catch (err) {
- goog.log.fine(
- this.logger_, this.formatMsg_('Error opening Xhr: ' + err.message));
- this.error_(goog.net.ErrorCode.EXCEPTION, err);
- return;
- }
-
-
-
- var content = opt_content || '';
- var headers = this.headers.clone();
-
- if (opt_headers) {
- goog.structs.forEach(
- opt_headers, function(value, key) { headers.set(key, value); });
- }
-
-
-
- var contentTypeKey =
- goog.array.find(headers.getKeys(), goog.net.XhrIo.isContentTypeHeader_);
- var contentIsFormData =
- (goog.global['FormData'] && (content instanceof goog.global['FormData']));
- if (goog.array.contains(goog.net.XhrIo.METHODS_WITH_FORM_DATA, method) &&
- !contentTypeKey && !contentIsFormData) {
-
-
-
-
- headers.set(
- goog.net.XhrIo.CONTENT_TYPE_HEADER, goog.net.XhrIo.FORM_CONTENT_TYPE);
- }
-
- headers.forEach(function(value, key) {
- this.xhr_.setRequestHeader(key, value);
- }, this);
- if (this.responseType_) {
- this.xhr_.responseType = this.responseType_;
- }
-
-
-
- if ('withCredentials' in this.xhr_ &&
- this.xhr_.withCredentials !== this.withCredentials_) {
- this.xhr_.withCredentials = this.withCredentials_;
- }
-
- try {
- this.cleanUpTimeoutTimer_();
- if (this.timeoutInterval_ > 0) {
- this.useXhr2Timeout_ = goog.net.XhrIo.shouldUseXhr2Timeout_(this.xhr_);
- goog.log.fine(
- this.logger_, this.formatMsg_(
- 'Will abort after ' + this.timeoutInterval_ +
- 'ms if incomplete, xhr2 ' + this.useXhr2Timeout_));
- if (this.useXhr2Timeout_) {
- this.xhr_[goog.net.XhrIo.XHR2_TIMEOUT_] = this.timeoutInterval_;
- this.xhr_[goog.net.XhrIo.XHR2_ON_TIMEOUT_] =
- goog.bind(this.timeout_, this);
- } else {
- this.timeoutId_ =
- goog.Timer.callOnce(this.timeout_, this.timeoutInterval_, this);
- }
- }
- goog.log.fine(this.logger_, this.formatMsg_('Sending request'));
- this.inSend_ = true;
- this.xhr_.send(content);
- this.inSend_ = false;
- } catch (err) {
- goog.log.fine(this.logger_, this.formatMsg_('Send error: ' + err.message));
- this.error_(goog.net.ErrorCode.EXCEPTION, err);
- }
- };
- goog.net.XhrIo.shouldUseXhr2Timeout_ = function(xhr) {
- return goog.userAgent.IE && goog.userAgent.isVersionOrHigher(9) &&
- goog.isNumber(xhr[goog.net.XhrIo.XHR2_TIMEOUT_]) &&
- goog.isDef(xhr[goog.net.XhrIo.XHR2_ON_TIMEOUT_]);
- };
- goog.net.XhrIo.isContentTypeHeader_ = function(header) {
- return goog.string.caseInsensitiveEquals(
- goog.net.XhrIo.CONTENT_TYPE_HEADER, header);
- };
- goog.net.XhrIo.prototype.createXhr = function() {
- return this.xmlHttpFactory_ ? this.xmlHttpFactory_.createInstance() :
- goog.net.XmlHttp();
- };
- goog.net.XhrIo.prototype.timeout_ = function() {
- if (typeof goog == 'undefined') {
-
-
- } else if (this.xhr_) {
- this.lastError_ =
- 'Timed out after ' + this.timeoutInterval_ + 'ms, aborting';
- this.lastErrorCode_ = goog.net.ErrorCode.TIMEOUT;
- goog.log.fine(this.logger_, this.formatMsg_(this.lastError_));
- this.dispatchEvent(goog.net.EventType.TIMEOUT);
- this.abort(goog.net.ErrorCode.TIMEOUT);
- }
- };
- goog.net.XhrIo.prototype.error_ = function(errorCode, err) {
- this.active_ = false;
- if (this.xhr_) {
- this.inAbort_ = true;
- this.xhr_.abort();
- this.inAbort_ = false;
- }
- this.lastError_ = err;
- this.lastErrorCode_ = errorCode;
- this.dispatchErrors_();
- this.cleanUpXhr_();
- };
- goog.net.XhrIo.prototype.dispatchErrors_ = function() {
- if (!this.errorDispatched_) {
- this.errorDispatched_ = true;
- this.dispatchEvent(goog.net.EventType.COMPLETE);
- this.dispatchEvent(goog.net.EventType.ERROR);
- }
- };
- goog.net.XhrIo.prototype.abort = function(opt_failureCode) {
- if (this.xhr_ && this.active_) {
- goog.log.fine(this.logger_, this.formatMsg_('Aborting'));
- this.active_ = false;
- this.inAbort_ = true;
- this.xhr_.abort();
- this.inAbort_ = false;
- this.lastErrorCode_ = opt_failureCode || goog.net.ErrorCode.ABORT;
- this.dispatchEvent(goog.net.EventType.COMPLETE);
- this.dispatchEvent(goog.net.EventType.ABORT);
- this.cleanUpXhr_();
- }
- };
- goog.net.XhrIo.prototype.disposeInternal = function() {
- if (this.xhr_) {
-
-
-
-
-
- if (this.active_) {
- this.active_ = false;
- this.inAbort_ = true;
- this.xhr_.abort();
- this.inAbort_ = false;
- }
- this.cleanUpXhr_(true);
- }
- goog.net.XhrIo.base(this, 'disposeInternal');
- };
- goog.net.XhrIo.prototype.onReadyStateChange_ = function() {
- if (this.isDisposed()) {
-
- return;
- }
- if (!this.inOpen_ && !this.inSend_ && !this.inAbort_) {
-
-
- this.onReadyStateChangeEntryPoint_();
- } else {
- this.onReadyStateChangeHelper_();
- }
- };
- goog.net.XhrIo.prototype.onReadyStateChangeEntryPoint_ = function() {
- this.onReadyStateChangeHelper_();
- };
- goog.net.XhrIo.prototype.onReadyStateChangeHelper_ = function() {
- if (!this.active_) {
-
- return;
- }
- if (typeof goog == 'undefined') {
-
-
- } else if (
- this.xhrOptions_[goog.net.XmlHttp.OptionType.LOCAL_REQUEST_ERROR] &&
- this.getReadyState() == goog.net.XmlHttp.ReadyState.COMPLETE &&
- this.getStatus() == 2) {
-
-
-
- goog.log.fine(
- this.logger_,
- this.formatMsg_('Local request error detected and ignored'));
- } else {
-
-
-
-
- if (this.inSend_ &&
- this.getReadyState() == goog.net.XmlHttp.ReadyState.COMPLETE) {
- goog.Timer.callOnce(this.onReadyStateChange_, 0, this);
- return;
- }
- this.dispatchEvent(goog.net.EventType.READY_STATE_CHANGE);
-
- if (this.isComplete()) {
- goog.log.fine(this.logger_, this.formatMsg_('Request complete'));
- this.active_ = false;
- try {
-
-
- if (this.isSuccess()) {
- this.dispatchEvent(goog.net.EventType.COMPLETE);
- this.dispatchEvent(goog.net.EventType.SUCCESS);
- } else {
- this.lastErrorCode_ = goog.net.ErrorCode.HTTP_ERROR;
- this.lastError_ =
- this.getStatusText() + ' [' + this.getStatus() + ']';
- this.dispatchErrors_();
- }
- } finally {
- this.cleanUpXhr_();
- }
- }
- }
- };
- goog.net.XhrIo.prototype.onProgressHandler_ = function(e, opt_isDownload) {
- goog.asserts.assert(
- e.type === goog.net.EventType.PROGRESS,
- 'goog.net.EventType.PROGRESS is of the same type as raw XHR progress.');
- this.dispatchEvent(
- goog.net.XhrIo.buildProgressEvent_(e, goog.net.EventType.PROGRESS));
- this.dispatchEvent(
- goog.net.XhrIo.buildProgressEvent_(
- e, opt_isDownload ? goog.net.EventType.DOWNLOAD_PROGRESS :
- goog.net.EventType.UPLOAD_PROGRESS));
- };
- goog.net.XhrIo.buildProgressEvent_ = function(e, eventType) {
- return ({
- type: eventType,
- lengthComputable: e.lengthComputable,
- loaded: e.loaded,
- total: e.total
- });
- };
- goog.net.XhrIo.prototype.cleanUpXhr_ = function(opt_fromDispose) {
- if (this.xhr_) {
-
- this.cleanUpTimeoutTimer_();
-
-
- var xhr = this.xhr_;
- var clearedOnReadyStateChange =
- this.xhrOptions_[goog.net.XmlHttp.OptionType.USE_NULL_FUNCTION] ?
- goog.nullFunction :
- null;
- this.xhr_ = null;
- this.xhrOptions_ = null;
- if (!opt_fromDispose) {
- this.dispatchEvent(goog.net.EventType.READY);
- }
- try {
-
-
-
-
- xhr.onreadystatechange = clearedOnReadyStateChange;
- } catch (e) {
-
-
-
- goog.log.error(
- this.logger_,
- 'Problem encountered resetting onreadystatechange: ' + e.message);
- }
- }
- };
- goog.net.XhrIo.prototype.cleanUpTimeoutTimer_ = function() {
- if (this.xhr_ && this.useXhr2Timeout_) {
- this.xhr_[goog.net.XhrIo.XHR2_ON_TIMEOUT_] = null;
- }
- if (goog.isNumber(this.timeoutId_)) {
- goog.Timer.clear(this.timeoutId_);
- this.timeoutId_ = null;
- }
- };
- goog.net.XhrIo.prototype.isActive = function() {
- return !!this.xhr_;
- };
- goog.net.XhrIo.prototype.isComplete = function() {
- return this.getReadyState() == goog.net.XmlHttp.ReadyState.COMPLETE;
- };
- goog.net.XhrIo.prototype.isSuccess = function() {
- var status = this.getStatus();
-
- return goog.net.HttpStatus.isSuccess(status) ||
- status === 0 && !this.isLastUriEffectiveSchemeHttp_();
- };
- goog.net.XhrIo.prototype.isLastUriEffectiveSchemeHttp_ = function() {
- var scheme = goog.uri.utils.getEffectiveScheme(String(this.lastUri_));
- return goog.net.XhrIo.HTTP_SCHEME_PATTERN.test(scheme);
- };
- goog.net.XhrIo.prototype.getReadyState = function() {
- return this.xhr_ ?
- (this.xhr_.readyState) :
- goog.net.XmlHttp.ReadyState
- .UNINITIALIZED;
- };
- goog.net.XhrIo.prototype.getStatus = function() {
-
- try {
- return this.getReadyState() > goog.net.XmlHttp.ReadyState.LOADED ?
- this.xhr_.status :
- -1;
- } catch (e) {
- return -1;
- }
- };
- goog.net.XhrIo.prototype.getStatusText = function() {
-
- try {
- return this.getReadyState() > goog.net.XmlHttp.ReadyState.LOADED ?
- this.xhr_.statusText :
- '';
- } catch (e) {
- goog.log.fine(this.logger_, 'Can not get status: ' + e.message);
- return '';
- }
- };
- goog.net.XhrIo.prototype.getLastUri = function() {
- return String(this.lastUri_);
- };
- goog.net.XhrIo.prototype.getResponseText = function() {
- try {
- return this.xhr_ ? this.xhr_.responseText : '';
- } catch (e) {
-
-
-
-
-
- goog.log.fine(this.logger_, 'Can not get responseText: ' + e.message);
- return '';
- }
- };
- goog.net.XhrIo.prototype.getResponseBody = function() {
- try {
- if (this.xhr_ && 'responseBody' in this.xhr_) {
- return this.xhr_['responseBody'];
- }
- } catch (e) {
-
-
- goog.log.fine(this.logger_, 'Can not get responseBody: ' + e.message);
- }
- return null;
- };
- goog.net.XhrIo.prototype.getResponseXml = function() {
- try {
- return this.xhr_ ? this.xhr_.responseXML : null;
- } catch (e) {
- goog.log.fine(this.logger_, 'Can not get responseXML: ' + e.message);
- return null;
- }
- };
- goog.net.XhrIo.prototype.getResponseJson = function(opt_xssiPrefix) {
- if (!this.xhr_) {
- return undefined;
- }
- var responseText = this.xhr_.responseText;
- if (opt_xssiPrefix && responseText.indexOf(opt_xssiPrefix) == 0) {
- responseText = responseText.substring(opt_xssiPrefix.length);
- }
- return goog.json.parse(responseText);
- };
- goog.net.XhrIo.prototype.getResponse = function() {
- try {
- if (!this.xhr_) {
- return null;
- }
- if ('response' in this.xhr_) {
- return this.xhr_.response;
- }
- switch (this.responseType_) {
- case goog.net.XhrIo.ResponseType.DEFAULT:
- case goog.net.XhrIo.ResponseType.TEXT:
- return this.xhr_.responseText;
-
-
-
-
-
- case goog.net.XhrIo.ResponseType.ARRAY_BUFFER:
- if ('mozResponseArrayBuffer' in this.xhr_) {
- return this.xhr_.mozResponseArrayBuffer;
- }
- }
-
- goog.log.error(
- this.logger_, 'Response type ' + this.responseType_ + ' is not ' +
- 'supported on this browser');
- return null;
- } catch (e) {
- goog.log.fine(this.logger_, 'Can not get response: ' + e.message);
- return null;
- }
- };
- goog.net.XhrIo.prototype.getResponseHeader = function(key) {
- if (!this.xhr_ || !this.isComplete()) {
- return undefined;
- }
- var value = this.xhr_.getResponseHeader(key);
- return goog.isNull(value) ? undefined : value;
- };
- goog.net.XhrIo.prototype.getAllResponseHeaders = function() {
- return this.xhr_ && this.isComplete() ? this.xhr_.getAllResponseHeaders() :
- '';
- };
- goog.net.XhrIo.prototype.getResponseHeaders = function() {
- var headersObject = {};
- var headersArray = this.getAllResponseHeaders().split('\r\n');
- for (var i = 0; i < headersArray.length; i++) {
- if (goog.string.isEmptyOrWhitespace(headersArray[i])) {
- continue;
- }
- var keyValue = goog.string.splitLimit(headersArray[i], ': ', 2);
- if (headersObject[keyValue[0]]) {
- headersObject[keyValue[0]] += ', ' + keyValue[1];
- } else {
- headersObject[keyValue[0]] = keyValue[1];
- }
- }
- return headersObject;
- };
- goog.net.XhrIo.prototype.getStreamingResponseHeader = function(key) {
- return this.xhr_ ? this.xhr_.getResponseHeader(key) : null;
- };
- goog.net.XhrIo.prototype.getAllStreamingResponseHeaders = function() {
- return this.xhr_ ? this.xhr_.getAllResponseHeaders() : '';
- };
- goog.net.XhrIo.prototype.getLastErrorCode = function() {
- return this.lastErrorCode_;
- };
- goog.net.XhrIo.prototype.getLastError = function() {
- return goog.isString(this.lastError_) ? this.lastError_ :
- String(this.lastError_);
- };
- goog.net.XhrIo.prototype.formatMsg_ = function(msg) {
- return msg + ' [' + this.lastMethod_ + ' ' + this.lastUri_ + ' ' +
- this.getStatus() + ']';
- };
- goog.debug.entryPointRegistry.register(
-
- function(transformer) {
- goog.net.XhrIo.prototype.onReadyStateChangeEntryPoint_ =
- transformer(goog.net.XhrIo.prototype.onReadyStateChangeEntryPoint_);
- });
|