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; |
+ } |
} |