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

Unified Diff: sdk/lib/_internal/pub/lib/src/barback/base_server.dart

Issue 314443003: Disable GZIP in pub serve’s HTTP server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/barback/base_server.dart
diff --git a/sdk/lib/_internal/pub/lib/src/barback/base_server.dart b/sdk/lib/_internal/pub/lib/src/barback/base_server.dart
index 81559214abce462c97d6879dd8914e8607b1fd15..95dc355562341cbab81f716af11186c0107c24e1 100644
--- a/sdk/lib/_internal/pub/lib/src/barback/base_server.dart
+++ b/sdk/lib/_internal/pub/lib/src/barback/base_server.dart
@@ -45,6 +45,7 @@ abstract class BaseServer<T> {
BaseServer(this.environment, this._server) {
shelf_io.serveRequests(Chain.track(_server), const shelf.Pipeline()
.addMiddleware(shelf.createMiddleware(errorHandler: _handleError))
+ .addMiddleware(shelf.createMiddleware(responseHandler: _disableGzip))
.addHandler(handleRequest));
}
@@ -121,4 +122,20 @@ abstract class BaseServer<T> {
close();
return new shelf.Response.internalServerError();
}
+
+ /// Disable GZIP responses.
+ ///
+ /// This is primarily to optimize pub's startup. Since the transformer
+ /// plug-ins are loaded over HTTP, we pay the hit to GZIP encode and decode
+ /// them. Disabling this improves startup time by about 5% on my test.
+ ///
+ // TODO(rnystrom): Remove this when #5187 is fixed and we don't have to use
Anders Johnsen 2014/06/03 07:08:49 Due to the fact that barback is always run localho
nweiz 2014/06/03 18:07:32 When the above issue is fixed, we won't be using H
Anders Johnsen 2014/06/03 18:37:18 You will still serve http content to the browser,
nweiz 2014/06/03 19:07:35 Ah, good point, you're probably right that that sh
+ // HTTP for isolates.
+ _disableGzip(shelf.Response response) {
+ if (!response.headers.containsKey('Content-Encoding')) {
+ return response.change(headers: {'Content-Encoding': ''});
+ }
+
+ return response;
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698