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

Side by Side Diff: tools/dom/templates/html/impl/impl_XMLHttpRequest.darttemplate

Issue 1135893003: Pass Redirect status higher than 307 through to the user (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « tests/html/xhr_test.dart ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 /** 7 /**
8 * A client-side XHR request for getting data from a URL, 8 * A client-side XHR request for getting data from a URL,
9 * formally known as XMLHttpRequest. 9 * formally known as XMLHttpRequest.
10 * 10 *
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 requestHeaders.forEach((header, value) { 214 requestHeaders.forEach((header, value) {
215 xhr.setRequestHeader(header, value); 215 xhr.setRequestHeader(header, value);
216 }); 216 });
217 } 217 }
218 218
219 if (onProgress != null) { 219 if (onProgress != null) {
220 xhr.onProgress.listen(onProgress); 220 xhr.onProgress.listen(onProgress);
221 } 221 }
222 222
223 xhr.onLoad.listen((e) { 223 xhr.onLoad.listen((e) {
224 // Note: file:// URIs have status of 0. 224 var accepted = xhr.status >= 200 && xhr.status < 300;
225 if ((xhr.status >= 200 && xhr.status < 300) || 225 var fileUri = xhr.status == 0; // file:// URIs have status of 0.
226 xhr.status == 0 || xhr.status == 304) { 226 var notModified = xhr.status == 304;
227 // Redirect status is specified up to 307, but others have been used in
228 // practice. Notably Google Drive uses 308 Resume Incomplete for
229 // resumable uploads, and it's also been used as a redirect. The
230 // redirect case will be handled by the browser before it gets to us,
231 // so if we see it we should pass it through to the user.
232 var unknownRedirect = xhr.status > 307 && xhr.status < 400;
233
234 if (accepted || fileUri || notModified || unknownRedirect) {
227 completer.complete(xhr); 235 completer.complete(xhr);
228 } else { 236 } else {
229 completer.completeError(e); 237 completer.completeError(e);
230 } 238 }
231 }); 239 });
232 240
233 xhr.onError.listen(completer.completeError); 241 xhr.onError.listen(completer.completeError);
234 242
235 if (sendData != null) { 243 if (sendData != null) {
236 xhr.send(sendData); 244 xhr.send(sendData);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 headers[key] = '${headers[key]}, $value'; 379 headers[key] = '${headers[key]}, $value';
372 } else { 380 } else {
373 headers[key] = value; 381 headers[key] = value;
374 } 382 }
375 } 383 }
376 return headers; 384 return headers;
377 } 385 }
378 386
379 $!MEMBERS 387 $!MEMBERS
380 } 388 }
OLDNEW
« no previous file with comments | « tests/html/xhr_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698