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

Side by Side Diff: generated/googleapis_beta/lib/src/common_internal.dart

Issue 698403003: Api roll 5: 2014-11-05 (Closed) Base URL: git@github.com:dart-lang/googleapis.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 library googleapis_beta.common_internal; 1 library googleapis_beta.common_internal;
2 2
3 import "dart:async"; 3 import "dart:async";
4 import "dart:convert"; 4 import "dart:convert";
5 import "dart:collection" as collection; 5 import "dart:collection" as collection;
6 6
7 import "package:crypto/crypto.dart" as crypto; 7 import "package:crypto/crypto.dart" as crypto;
8 import "../common/common.dart" as common_external; 8 import "../common/common.dart" as common_external;
9 import "package:http/http.dart" as http; 9 import "package:http/http.dart" as http;
10 10
11 const String USER_AGENT_STRING = 11 const String USER_AGENT_STRING =
12 'google-api-dart-client googleapis_beta/0.4.0'; 12 'google-api-dart-client googleapis_beta/0.5.0';
13 13
14 const CONTENT_TYPE_JSON_UTF8 = 'application/json; charset=utf-8'; 14 const CONTENT_TYPE_JSON_UTF8 = 'application/json; charset=utf-8';
15 15
16 /** 16 /**
17 * Base class for all API clients, offering generic methods for 17 * Base class for all API clients, offering generic methods for
18 * HTTP Requests to the API 18 * HTTP Requests to the API
19 */ 19 */
20 class ApiRequester { 20 class ApiRequester {
21 final http.Client _httpClient; 21 final http.Client _httpClient;
22 final String _rootUrl; 22 final String _rootUrl;
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 var end = lastChunk.endOfChunk; 475 var end = lastChunk.endOfChunk;
476 476
477 // Validate that we have the correct number of bytes if length was 477 // Validate that we have the correct number of bytes if length was
478 // specified. 478 // specified.
479 if (_uploadMedia.length != null) { 479 if (_uploadMedia.length != null) {
480 if (end < _uploadMedia.length) { 480 if (end < _uploadMedia.length) {
481 completer.completeError(new common_external.ApiRequestError( 481 completer.completeError(new common_external.ApiRequestError(
482 'Received less bytes than indicated by [Media.length].')); 482 'Received less bytes than indicated by [Media.length].'));
483 return; 483 return;
484 } else if (end > _uploadMedia.length) { 484 } else if (end > _uploadMedia.length) {
485 completer.completeError( 485 completer.completeError(new common_external.ApiRequestError(
486 'Received more bytes than indicated by [Media.length].'); 486 'Received more bytes than indicated by [Media.length].'));
487 return; 487 return;
488 } 488 }
489 } 489 }
490 490
491 // Upload last chunk and *do not drain the response* but complete 491 // Upload last chunk and *do not drain the response* but complete
492 // with it. 492 // with it.
493 _uploadChunkResumable(uploadUri, lastChunk, lastChunk: true) 493 _uploadChunkResumable(uploadUri, lastChunk, lastChunk: true)
494 .then((response) { 494 .then((response) {
495 completer.complete(response); 495 completer.complete(response);
496 }).catchError((error, stack) { 496 }).catchError((error, stack) {
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 assert(key != null); 912 assert(key != null);
913 if(convert == null) { 913 if(convert == null) {
914 result[key] = value; 914 result[key] = value;
915 } else { 915 } else {
916 result[key] = convert(value); 916 result[key] = convert(value);
917 } 917 }
918 }); 918 });
919 return result; 919 return result;
920 } 920 }
921 921
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698