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

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

Issue 23596007: Remove usage of dart:json. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase. Created 7 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 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library lish.utils; 5 library lish.utils;
6 6
7 import 'dart:convert';
7 import 'dart:io'; 8 import 'dart:io';
8 import 'dart:json' as json;
9 9
10 import 'package:scheduled_test/scheduled_test.dart'; 10 import 'package:scheduled_test/scheduled_test.dart';
11 import 'package:scheduled_test/scheduled_server.dart'; 11 import 'package:scheduled_test/scheduled_server.dart';
12 12
13 import '../../lib/src/io.dart'; 13 import '../../lib/src/io.dart';
14 14
15 void handleUploadForm(ScheduledServer server, [Map body]) { 15 void handleUploadForm(ScheduledServer server, [Map body]) {
16 server.handle('GET', '/api/packages/versions/new', (request) { 16 server.handle('GET', '/api/packages/versions/new', (request) {
17 return server.url.then((url) { 17 return server.url.then((url) {
18 expect(request.headers.value('authorization'), 18 expect(request.headers.value('authorization'),
19 equals('Bearer access token')); 19 equals('Bearer access token'));
20 20
21 if (body == null) { 21 if (body == null) {
22 body = { 22 body = {
23 'url': url.resolve('/upload').toString(), 23 'url': url.resolve('/upload').toString(),
24 'fields': { 24 'fields': {
25 'field1': 'value1', 25 'field1': 'value1',
26 'field2': 'value2' 26 'field2': 'value2'
27 } 27 }
28 }; 28 };
29 } 29 }
30 30
31 request.response.headers.contentType = 31 request.response.headers.contentType =
32 new ContentType("application", "json"); 32 new ContentType("application", "json");
33 request.response.write(json.stringify(body)); 33 request.response.write(JSON.encode(body));
34 request.response.close(); 34 request.response.close();
35 }); 35 });
36 }); 36 });
37 } 37 }
38 38
39 void handleUpload(ScheduledServer server) { 39 void handleUpload(ScheduledServer server) {
40 server.handle('POST', '/upload', (request) { 40 server.handle('POST', '/upload', (request) {
41 // TODO(nweiz): Once a multipart/form-data parser in Dart exists, validate 41 // TODO(nweiz): Once a multipart/form-data parser in Dart exists, validate
42 // that the request body is correctly formatted. See issue 6952. 42 // that the request body is correctly formatted. See issue 6952.
43 return drainStream(request).then((_) { 43 return drainStream(request).then((_) {
44 return server.url; 44 return server.url;
45 }).then((url) { 45 }).then((url) {
46 request.response.statusCode = 302; 46 request.response.statusCode = 302;
47 request.response.headers.set( 47 request.response.headers.set(
48 'location', url.resolve('/create').toString()); 48 'location', url.resolve('/create').toString());
49 request.response.close(); 49 request.response.close();
50 }); 50 });
51 }); 51 });
52 } 52 }
53 53
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698