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

Unified Diff: sdk/lib/_internal/pub/lib/src/http.dart

Issue 238083002: Don't time out when uploading a package for "pub lish". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub/lib/src/http.dart
diff --git a/sdk/lib/_internal/pub/lib/src/http.dart b/sdk/lib/_internal/pub/lib/src/http.dart
index afaefd81b9795d28ba73942975897e7facccce38..08c30fd56ee95ea2b4d93aa8a4a6147279058488 100644
--- a/sdk/lib/_internal/pub/lib/src/http.dart
+++ b/sdk/lib/_internal/pub/lib/src/http.dart
@@ -34,6 +34,10 @@ 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.
+///
+/// This also adds a 30-second timeout to every request. This can be configured
+/// on a per-request basis by setting the 'Pub-Request-Timeout' header to the
+/// desired number of milliseconds, or to "None" to disable the timeout.
class PubHttpClient extends http.BaseClient {
final _requestStopwatches = new Map<http.BaseRequest, Stopwatch>();
@@ -55,7 +59,15 @@ class PubHttpClient extends http.BaseClient {
stackTrace = localStackTrace;
}
- return timeout(inner.send(request).then((streamedResponse) {
+ var timeoutLength = HTTP_TIMEOUT;
+ var timeoutString = request.headers.remove('Pub-Request-Timeout');
+ if (timeoutString == 'None') {
+ timeoutLength = null;
+ } else if (timeoutString != null) {
+ timeoutLength = int.parse(timeoutString);
+ }
+
+ var future = inner.send(request).then((streamedResponse) {
_logResponse(streamedResponse);
var status = streamedResponse.statusCode;
@@ -95,7 +107,10 @@ class PubHttpClient extends http.BaseClient {
}
}
throw error;
- }), HTTP_TIMEOUT, 'fetching URL "${request.url}"');
+ });
+
+ if (timeoutLength == null) return future;
+ return timeout(future, timeoutLength, 'fetching URL "${request.url}"');
}
/// Logs the fact that [request] was sent, and information about it.

Powered by Google App Engine
This is Rietveld 408576698