| Index: sdk/lib/_internal/pub_generated/lib/src/http.dart
|
| diff --git a/sdk/lib/_internal/pub/lib/src/http.dart b/sdk/lib/_internal/pub_generated/lib/src/http.dart
|
| similarity index 81%
|
| copy from sdk/lib/_internal/pub/lib/src/http.dart
|
| copy to sdk/lib/_internal/pub_generated/lib/src/http.dart
|
| index 4fe118eb25c238e8df4dc24be2c8b0757e6f8982..eea72ae86b47fa6c76e9e25cdc2d8d0b332e372d 100644
|
| --- a/sdk/lib/_internal/pub/lib/src/http.dart
|
| +++ b/sdk/lib/_internal/pub_generated/lib/src/http.dart
|
| @@ -31,7 +31,9 @@ final _CENSORED_FIELDS = const ['refresh_token', 'authorization'];
|
| /// The Accept header tells pub.dartlang.org which version of the API we're
|
| /// expecting, so it can either serve that version or give us a 406 error if
|
| /// it's not supported.
|
| -final PUB_API_HEADERS = const {'Accept': 'application/vnd.pub.v2+json'};
|
| +final PUB_API_HEADERS = const {
|
| + 'Accept': 'application/vnd.pub.v2+json'
|
| +};
|
|
|
| /// An HTTP client that transforms 40* errors and socket exceptions into more
|
| /// user-friendly error messages.
|
| @@ -75,29 +77,29 @@ class _PubHttpClient extends http.BaseClient {
|
| // 401 responses should be handled by the OAuth2 client. It's very
|
| // unlikely that they'll be returned by non-OAuth2 requests. We also want
|
| // to pass along 400 responses from the token endpoint.
|
| - var tokenRequest = urisEqual(
|
| - streamedResponse.request.url, oauth2.tokenEndpoint);
|
| + var tokenRequest =
|
| + urisEqual(streamedResponse.request.url, oauth2.tokenEndpoint);
|
| if (status < 400 || status == 401 || (status == 400 && tokenRequest)) {
|
| return streamedResponse;
|
| }
|
|
|
| if (status == 406 &&
|
| request.headers['Accept'] == PUB_API_HEADERS['Accept']) {
|
| - fail("Pub ${sdk.version} is incompatible with the current version of "
|
| - "${request.url.host}.\n"
|
| - "Upgrade pub to the latest version and try again.");
|
| + fail(
|
| + "Pub ${sdk.version} is incompatible with the current version of "
|
| + "${request.url.host}.\n" "Upgrade pub to the latest version and try again.");
|
| }
|
|
|
| if (status == 500 &&
|
| (request.url.host == "pub.dartlang.org" ||
|
| - request.url.host == "storage.googleapis.com")) {
|
| - var message = "HTTP error 500: Internal Server Error at "
|
| - "${request.url}.";
|
| + request.url.host == "storage.googleapis.com")) {
|
| + var message =
|
| + "HTTP error 500: Internal Server Error at " "${request.url}.";
|
|
|
| if (request.url.host == "pub.dartlang.org" ||
|
| request.url.host == "storage.googleapis.com") {
|
| - message += "\nThis is likely a transient error. Please try again "
|
| - "later.";
|
| + message +=
|
| + "\nThis is likely a transient error. Please try again " "later.";
|
| }
|
|
|
| fail(message);
|
| @@ -107,26 +109,31 @@ class _PubHttpClient extends http.BaseClient {
|
| throw new PubHttpException(response);
|
| });
|
| }).catchError((error, stackTrace) {
|
| - if (error is SocketException &&
|
| - error.osError != null) {
|
| + if (error is SocketException && error.osError != null) {
|
| if (error.osError.errorCode == 8 ||
|
| error.osError.errorCode == -2 ||
|
| error.osError.errorCode == -5 ||
|
| error.osError.errorCode == 11001 ||
|
| error.osError.errorCode == 11004) {
|
| - fail('Could not resolve URL "${request.url.origin}".',
|
| - error, stackTrace);
|
| + fail(
|
| + 'Could not resolve URL "${request.url.origin}".',
|
| + error,
|
| + stackTrace);
|
| } else if (error.osError.errorCode == -12276) {
|
| - fail('Unable to validate SSL certificate for '
|
| - '"${request.url.origin}".',
|
| - error, stackTrace);
|
| + fail(
|
| + 'Unable to validate SSL certificate for ' '"${request.url.origin}".',
|
| + error,
|
| + stackTrace);
|
| }
|
| }
|
| throw error;
|
| });
|
|
|
| if (timeoutLength == null) return future;
|
| - return timeout(future, timeoutLength, request.url,
|
| + return timeout(
|
| + future,
|
| + timeoutLength,
|
| + request.url,
|
| 'fetching URL "${request.url}"');
|
| }
|
|
|
| @@ -134,8 +141,8 @@ class _PubHttpClient extends http.BaseClient {
|
| void _logRequest(http.BaseRequest request) {
|
| var requestLog = new StringBuffer();
|
| requestLog.writeln("HTTP ${request.method} ${request.url}");
|
| - request.headers.forEach((name, value) =>
|
| - requestLog.writeln(_logField(name, value)));
|
| + request.headers.forEach(
|
| + (name, value) => requestLog.writeln(_logField(name, value)));
|
|
|
| if (request.method == 'POST') {
|
| var contentTypeString = request.headers[HttpHeaders.CONTENT_TYPE];
|
| @@ -144,16 +151,16 @@ class _PubHttpClient extends http.BaseClient {
|
| if (request is http.MultipartRequest) {
|
| requestLog.writeln();
|
| requestLog.writeln("Body fields:");
|
| - request.fields.forEach((name, value) =>
|
| - requestLog.writeln(_logField(name, value)));
|
| + request.fields.forEach(
|
| + (name, value) => requestLog.writeln(_logField(name, value)));
|
|
|
| // TODO(nweiz): make MultipartRequest.files readable, and log them?
|
| } else if (request is http.Request) {
|
| if (contentType.value == 'application/x-www-form-urlencoded') {
|
| requestLog.writeln();
|
| requestLog.writeln("Body fields:");
|
| - request.bodyFields.forEach((name, value) =>
|
| - requestLog.writeln(_logField(name, value)));
|
| + request.bodyFields.forEach(
|
| + (name, value) => requestLog.writeln(_logField(name, value)));
|
| } else if (contentType.value == 'text/plain' ||
|
| contentType.value == 'application/json') {
|
| requestLog.write(request.body);
|
| @@ -172,11 +179,12 @@ class _PubHttpClient extends http.BaseClient {
|
| var responseLog = new StringBuffer();
|
| var request = response.request;
|
| var stopwatch = _requestStopwatches.remove(request)..stop();
|
| - responseLog.writeln("HTTP response ${response.statusCode} "
|
| - "${response.reasonPhrase} for ${request.method} ${request.url}");
|
| + responseLog.writeln(
|
| + "HTTP response ${response.statusCode} "
|
| + "${response.reasonPhrase} for ${request.method} ${request.url}");
|
| responseLog.writeln("took ${stopwatch.elapsed}");
|
| - response.headers.forEach((name, value) =>
|
| - responseLog.writeln(_logField(name, value)));
|
| + response.headers.forEach(
|
| + (name, value) => responseLog.writeln(_logField(name, value)));
|
|
|
| log.fine(responseLog.toString().trim());
|
| }
|
| @@ -249,7 +257,7 @@ Map parseJsonResponse(http.Response response) {
|
|
|
| /// Throws an error describing an invalid response from the server.
|
| void invalidServerResponse(http.Response response) =>
|
| - fail('Invalid server response:\n${response.body}');
|
| + fail('Invalid server response:\n${response.body}');
|
|
|
| /// Exception thrown when an HTTP operation fails.
|
| class PubHttpException implements Exception {
|
| @@ -257,6 +265,6 @@ class PubHttpException implements Exception {
|
|
|
| const PubHttpException(this.response);
|
|
|
| - String toString() => 'HTTP error ${response.statusCode}: '
|
| - '${response.reasonPhrase}';
|
| + String toString() =>
|
| + 'HTTP error ${response.statusCode}: ' '${response.reasonPhrase}';
|
| }
|
|
|