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

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

Issue 557563002: Store the async-await compiled pub code directly in the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
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; 1 library lish.utils;
6
7 import 'dart:convert'; 2 import 'dart:convert';
8
9 import 'package:scheduled_test/scheduled_test.dart'; 3 import 'package:scheduled_test/scheduled_test.dart';
10 import 'package:scheduled_test/scheduled_server.dart'; 4 import 'package:scheduled_test/scheduled_server.dart';
11 import 'package:shelf/shelf.dart' as shelf; 5 import 'package:shelf/shelf.dart' as shelf;
12
13 import '../../lib/src/io.dart'; 6 import '../../lib/src/io.dart';
14
15 void handleUploadForm(ScheduledServer server, [Map body]) { 7 void handleUploadForm(ScheduledServer server, [Map body]) {
16 server.handle('GET', '/api/packages/versions/new', (request) { 8 server.handle('GET', '/api/packages/versions/new', (request) {
17 return server.url.then((url) { 9 return server.url.then((url) {
18 expect(request.headers, 10 expect(
11 request.headers,
19 containsPair('authorization', 'Bearer access token')); 12 containsPair('authorization', 'Bearer access token'));
20
21 if (body == null) { 13 if (body == null) {
22 body = { 14 body = {
23 'url': url.resolve('/upload').toString(), 15 'url': url.resolve('/upload').toString(),
24 'fields': { 16 'fields': {
25 'field1': 'value1', 17 'field1': 'value1',
26 'field2': 'value2' 18 'field2': 'value2'
27 } 19 }
28 }; 20 };
29 } 21 }
30 22 return new shelf.Response.ok(JSON.encode(body), headers: {
31 return new shelf.Response.ok(JSON.encode(body), 23 'content-type': 'application/json'
32 headers: {'content-type': 'application/json'}); 24 });
33 }); 25 });
34 }); 26 });
35 } 27 }
36
37 void handleUpload(ScheduledServer server) { 28 void handleUpload(ScheduledServer server) {
38 server.handle('POST', '/upload', (request) { 29 server.handle('POST', '/upload', (request) {
39 // TODO(nweiz): Once a multipart/form-data parser in Dart exists, validate 30 return drainStream(
40 // that the request body is correctly formatted. See issue 6952. 31 request.read()).then(
41 return drainStream(request.read()) 32 (_) =>
42 .then((_) => server.url) 33 server.url).then((url) => new shelf.Response.found(url.resolve(' /create')));
43 .then((url) => new shelf.Response.found(url.resolve('/create')));
44 }); 34 });
45 } 35 }
46
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698