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

Side by Side Diff: sdk/lib/_internal/pub_generated/test/lish/utils.dart

Issue 896623005: Use native async/await support in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 library lish.utils;
6
7 import 'dart:convert';
8
9 import 'package:scheduled_test/scheduled_test.dart';
10 import 'package:scheduled_test/scheduled_server.dart';
11 import 'package:shelf/shelf.dart' as shelf;
12
13 import '../../lib/src/io.dart';
14
15 void handleUploadForm(ScheduledServer server, [Map body]) {
16 server.handle('GET', '/api/packages/versions/new', (request) {
17 return server.url.then((url) {
18 expect(
19 request.headers,
20 containsPair('authorization', 'Bearer access token'));
21
22 if (body == null) {
23 body = {
24 'url': url.resolve('/upload').toString(),
25 'fields': {
26 'field1': 'value1',
27 'field2': 'value2'
28 }
29 };
30 }
31
32 return new shelf.Response.ok(JSON.encode(body), headers: {
33 'content-type': 'application/json'
34 });
35 });
36 });
37 }
38
39 void handleUpload(ScheduledServer server) {
40 server.handle('POST', '/upload', (request) {
41 // TODO(nweiz): Once a multipart/form-data parser in Dart exists, validate
42 // that the request body is correctly formatted. See issue 6952.
43 return drainStream(
44 request.read()).then(
45 (_) =>
46 server.url).then((url) => new shelf.Response.found(url.resolve(' /create')));
47 });
48 }
49
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698