Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: remoting/webapp/crd/js/xhr.js

Issue 1039853002: Added isError method to remoting.Xhr.Error to check for HTTP errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | remoting/webapp/crd/js/xhr_unittest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Utility class for making XHRs more pleasant. 7 * Utility class for making XHRs more pleasant.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 this.url = xhr.responseURL; 287 this.url = xhr.responseURL;
288 288
289 /** @private {string} */ 289 /** @private {string} */
290 this.text_ = xhr.responseText || ''; 290 this.text_ = xhr.responseText || '';
291 291
292 /** @private {*|undefined} */ 292 /** @private {*|undefined} */
293 this.json_ = undefined; 293 this.json_ = undefined;
294 }; 294 };
295 295
296 /** 296 /**
297 * @return {boolean} True if the response code is outside the 200-299
298 * range (i.e. success as defined by the HTTP protocol).
299 */
300 remoting.Xhr.Response.prototype.isError = function() {
301 return this.status < 200 || this.status >= 300;
302 };
303
304 /**
297 * @return {string} The text content of the response. 305 * @return {string} The text content of the response.
298 */ 306 */
299 remoting.Xhr.Response.prototype.getText = function() { 307 remoting.Xhr.Response.prototype.getText = function() {
300 return this.text_; 308 return this.text_;
301 }; 309 };
302 310
303 /** 311 /**
304 * Get the JSON content of the response. Requires acceptJson to have 312 * Get the JSON content of the response. Requires acceptJson to have
305 * been true in the request. 313 * been true in the request.
306 * @return {*} The parsed JSON content of the response. 314 * @return {*} The parsed JSON content of the response.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 var paramArray = []; 353 var paramArray = [];
346 for (var key in paramHash) { 354 for (var key in paramHash) {
347 paramArray.push(encodeURIComponent(key) + 355 paramArray.push(encodeURIComponent(key) +
348 '=' + encodeURIComponent(paramHash[key])); 356 '=' + encodeURIComponent(paramHash[key]));
349 } 357 }
350 if (paramArray.length > 0) { 358 if (paramArray.length > 0) {
351 return paramArray.join('&'); 359 return paramArray.join('&');
352 } 360 }
353 return ''; 361 return '';
354 }; 362 };
OLDNEW
« no previous file with comments | « no previous file | remoting/webapp/crd/js/xhr_unittest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698