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

Unified Diff: sdk/lib/_internal/pub/test/oauth2/utils.dart

Issue 216373004: Use shelf handlers in ScheduledServer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 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/test/oauth2/utils.dart
diff --git a/sdk/lib/_internal/pub/test/oauth2/utils.dart b/sdk/lib/_internal/pub/test/oauth2/utils.dart
index 5144dade17511ffe2dd3dc8839a9d35c5e99a8eb..fc9b4c511ca8b9e833ed09bb6137729231847c14 100644
--- a/sdk/lib/_internal/pub/test/oauth2/utils.dart
+++ b/sdk/lib/_internal/pub/test/oauth2/utils.dart
@@ -11,6 +11,7 @@ import 'package:http/http.dart' as http;
import 'package:scheduled_test/scheduled_process.dart';
import 'package:scheduled_test/scheduled_test.dart';
import 'package:scheduled_test/scheduled_server.dart';
+import 'package:shelf/shelf.dart' as shelf;
import '../../lib/src/io.dart';
import '../../lib/src/utils.dart';
@@ -41,17 +42,13 @@ void authorizePub(ScheduledProcess pub, ScheduledServer server,
void handleAccessTokenRequest(ScheduledServer server, String accessToken) {
server.handle('POST', '/token', (request) {
- return new ByteStream(request).toBytes().then((bytes) {
- var body = new String.fromCharCodes(bytes);
+ return request.readAsString().then((body) {
expect(body, matches(new RegExp(r'(^|&)code=access\+code(&|$)')));
- request.response.headers.contentType =
- new ContentType("application", "json");
- request.response.write(JSON.encode({
+ return new shelf.Response.ok(JSON.encode({
"access_token": accessToken,
"token_type": "bearer"
- }));
- request.response.close();
+ }), headers: {'content-type': 'application/json'});
});
});
}

Powered by Google App Engine
This is Rietveld 408576698