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

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

Issue 311253005: Bind to all available loopback addresses in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 6 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 | « sdk/lib/_internal/pub/lib/src/io.dart ('k') | sdk/lib/_internal/pub/lib/src/source/hosted.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/oauth2.dart
diff --git a/sdk/lib/_internal/pub/lib/src/oauth2.dart b/sdk/lib/_internal/pub/lib/src/oauth2.dart
index b1edba05d9bb1b393d5ef947f97d0a7a82ae5c0d..ce344bbf546338b1fbc95d1738068d2b5dc35dba 100644
--- a/sdk/lib/_internal/pub/lib/src/oauth2.dart
+++ b/sdk/lib/_internal/pub/lib/src/oauth2.dart
@@ -169,29 +169,28 @@ Future<Client> _authorize() {
// Spin up a one-shot HTTP server to receive the authorization code from the
// Google OAuth2 server via redirect. This server will close itself as soon as
// the code is received.
- var server;
var completer = new Completer();
- shelf_io.serve((request) {
- if (request.url.path != "/") {
- return new shelf.Response.notFound('Invalid URI.');
- }
+ bindServer('localhost', 0).then((server) {
+ shelf_io.serveRequests(server, (request) {
+ if (request.url.path != "/") {
+ return new shelf.Response.notFound('Invalid URI.');
+ }
- log.message('Authorization received, processing...');
- var queryString = request.url.query;
- if (queryString == null) queryString = '';
+ log.message('Authorization received, processing...');
+ var queryString = request.url.query;
+ if (queryString == null) queryString = '';
- // Closing the server here is safe, since it will wait until the response is
- // sent to actually shut down.
- server.close();
- chainToCompleter(grant.handleAuthorizationResponse(queryToMap(queryString)),
- completer);
+ // Closing the server here is safe, since it will wait until the response
+ // is sent to actually shut down.
+ server.close();
+ chainToCompleter(grant.handleAuthorizationResponse(queryToMap(queryString)),
+ completer);
- return new shelf.Response.found('http://pub.dartlang.org/authorized');
- }, '127.0.0.1', 0).then((server_) {
- server = server_;
+ return new shelf.Response.found('http://pub.dartlang.org/authorized');
+ });
var authUrl = grant.getAuthorizationUrl(
- Uri.parse('http://127.0.0.1:${server.port}'), scopes: _scopes);
+ Uri.parse('http://localhost:${server.port}'), scopes: _scopes);
log.message(
'Pub needs your authorization to upload packages on your behalf.\n'
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/io.dart ('k') | sdk/lib/_internal/pub/lib/src/source/hosted.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698