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

Side by Side Diff: pkg/http/README.md

Issue 89433002: Create a first-cut for a README for http package (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: get close to 79/80 Created 7 years 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
« no previous file with comments | « no previous file | pkg/http/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # A composable, Future-based library for making HTTP requests.
nweiz 2013/11/27 01:51:39 This shouldn't all be part of an h1.
2
3 This package contains a set of high-level functions and classes that make it
4 easy to consume HTTP resources.
nweiz 2013/11/27 01:51:39 "consume HTTP resources" sounds stilted to me. Als
5
6 **NOTE:** This package only works for
nweiz 2013/11/27 01:51:39 "only works" -> "currently only works" As soon as
7 server-side or command-line Dart applications. In other words, if the app
8 imports `dart:io`, it can use this package.
nweiz 2013/11/27 01:51:39 Fix the word-wrapping in this paragraph.
9
10 ## Installing
11
12 See the [http package on pub][hosted] for installation instructions.
nweiz 2013/11/27 01:51:39 Since pub is widely-known now, installation instru
13
14 ## Reading text from a resource
nweiz 2013/11/27 01:51:39 I think using REST-style "resource" terminology is
15
16 Use the `read()` function to easily GET an HTTP or HTTPS resource.
17 The returned future completes with a String of the response body,
18 or completes with an error.
19
20 import 'package:http/http.dart' as http;
21
22 void main() {
23 http.read('https://www.example.com/').then((String contents) {
nweiz 2013/11/27 01:51:39 Don't include type annotations for closure paramet
24 print(contents);
25 });
26 }
27
28 ## Reading bytes from a resource
29
30 Use the `readBytes()` function to GET a list of bytes from an HTTP or HTTPS
31 resource.
32
33 import 'package:http/http.dart' as http;
34
35 void main() {
36 http.read('https://www.example.com/binary').then((Uint8List bytes) {
37 print(contents.length);
38 });
39 }
nweiz 2013/11/27 01:51:39 I don't think this is distinct enough from the pre
40
41 ## Streaming bytes from a resource
nweiz 2013/11/27 01:51:39 Streaming isn't a common use-case; certainly not m
42
43 Create a new `Client` to stream the bytes from a resource.
44
45 import 'package:http/http.dart';
nweiz 2013/11/27 01:51:39 http is intended to be imported with a prefix.
46
47 main() {
48 var client = new Client();
49
50 client.send(new Request('GET', Uri.parse('http://www.google.com/')))
51 .then((StreamedResponse resp) {
nweiz 2013/11/27 01:51:39 Indent this line +4 spaces.
52 // After the headers have been received.
53 resp.stream.listen((List<int> bytes) {
54 print('Received ${bytes.length} bytes');
55 });
56 });
57 }
58
59 ## Posting to a resource
60
61 Use the `post()` function to easily POST a body to an HTTP or HTTPS resource.
62
63 import 'package:http/http.dart' as http;
64
65 var url = "http://example.com/whatsit/create";
66 http.post(url, body: {"name": "doodle", "color": "blue"})
67 .then((http.Response response) {
68 print("Response status: ${response.statusCode}");
69 print("Response body: ${response.body}");
70 });
71
72 http.read("http://example.com/foobar.txt").then(print);
73
74 ## HTTP methods
75
76 There are top-level functions for each of the main HTTP methods. Each
77 returns a `Future<Response>`.
78
79 * `get()`
80 * `post()`
81 * `delete()`
82 * `put()`
83 * `head()`
84
85 ## API docs
86
87 Coming soon.
nweiz 2013/11/27 01:51:39 The docs are now available at http://test.dartdoc-
88
89 ## Filing issues
90
91 Please file issues for the http package at [http://dartbug.com/new][bugs].
92
93 [hosted]: https://pub.dartlang.org/packages/http
94 [bugs]: http://dartbug.com/new
OLDNEW
« no previous file with comments | « no previous file | pkg/http/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698