Skip to content
Newer
Older
100644 158 lines (101 sloc) 4.03 KB
d304a58 Initial commit.
cloudhead authored
1 http-console
2 ============
3
4 > Speak HTTP like a local
5
bd28411 (doc) README prelude
cloudhead authored
6 Talking to an HTTP server with `curl` can be fun, but most of the time it's a `PITA`.
7
8 `http-console` is a simple and intuitive interface for speaking the HTTP protocol.
9
10 *PS: HTTP has never been this much fun.*
74ccfff (doc) updated README
cloudhead authored
11
d304a58 Initial commit.
cloudhead authored
12 synopsis
13 --------
14
0ec7e99 (doc) screenshot
cloudhead authored
15 ![http-console](http://dl.dropbox.com/u/251849/http-console.png)
d304a58 Initial commit.
cloudhead authored
16
17 installation
18 ------------
19
ddc7936 (doc) install instructions for non-noders
cloudhead authored
20 *http-console* was written for [node](http://nodejs.org), so make sure you have that installed
21 first. Then you need [npm](http://github.com/isaacs/npm), node's package manager.
22
23 Once you're all set, run:
24
d304a58 Initial commit.
cloudhead authored
25 $ npm install http-console
26
ddc7936 (doc) install instructions for non-noders
cloudhead authored
27 It'll download the dependencies, and install the command-line tool in `/usr/local/bin`.
28
76e54aa (doc) some more install instructions
cloudhead authored
29 ### Installing the bleeding edge #
30
31 The latest release will often be available on npm as `http-console@latest`, so you can run:
32
33 $ npm install http-console@latest
34
35 Alternatively, you can download a tarball of this repo, or clone it. Just make sure you have
914e310 (doc) update README
cloudhead authored
36 the latest version of node.
76e54aa (doc) some more install instructions
cloudhead authored
37
d304a58 Initial commit.
cloudhead authored
38 introduction
39 ------------
40
41 Let's assume we have a [CouchDB](http://couchdb.apache.org) instance running locally.
42
43 ### connecting #
44
45 To connect, we run `http-console`, passing it the server host and port as such:
46
47 $ http-console 127.0.0.1:5984
48
49 ### navigating #
50
51 Once connected, we should see the *http prompt*:
52
53 http://127.0.0.1:5984/>
54
55 server navigation is similar to directory navigation, except a little simpler:
56
57 http://127.0.0.1:5984/> /logs
58 http://127.0.0.1:5984/logs> /46
59 http://127.0.0.1:5984/logs/46> ..
60 http://127.0.0.1:5984/logs> ..
61 http://127.0.0.1:5984/>
62
63 ### requesting #
64
65 HTTP requests are issued with the HTTP verbs *GET*, *PUT*, *POST*, *HEAD* and *DELETE*, and
66 a relative path:
67
68 http://127.0.0.1:5984/> GET /
69 HTTP/1.1 200 OK
70 Date: Mon, 31 May 2010 04:43:39 GMT
71 Content-Length: 41
72
73 {
74 couchdb: "Welcome",
75 version: "0.11.0"
76 }
77
78 http://127.0.0.1:5984/> GET /bob
79 HTTP/1.1 404 Not Found
80 Date: Mon, 31 May 2010 04:45:32 GMT
81 Content-Length: 44
82
83 {
84 error: "not_found",
85 reason: "no_db_file"
86 }
87
88 When issuing *POST* and *PUT* commands, we have the opportunity to send data too:
89
90 http://127.0.0.1:5984/> /rabbits
91 http://127.0.0.1:5984/rabbits> POST
92 ... {"name":"Roger"}
93
94 HTTP/1.1 201 Created
28acbb5 (doc) fix README
cloudhead authored
95 Location: http://127.0.0.1/rabbits/2fd9db055885e6982462a10e54003127
d304a58 Initial commit.
cloudhead authored
96 Date: Mon, 31 May 2010 05:09:15 GMT
97 Content-Length: 95
98
99 {
100 ok: true,
101 id: "2fd9db055885e6982462a10e54003127",
102 rev: "1-0c3db91854f26486d1c3922f1a651d86"
103 }
104
0b07809 (doc) updated README
cloudhead authored
105 Make sure you have your `Content-Type` header set properly, if the API requires it. More
106 in the section below.
107
108 > Note that if you're trying to POST to a form handler, you'll most probably want to send data
109 in `multipart/form-data` format, such as `name=roger&hair=black`. http-console sends your POST/PUT data *as is*,
110 so make sure you've got the format right, and the appropriate `Content-Type` header.
111
d304a58 Initial commit.
cloudhead authored
112 ### setting headers #
113
114 Sometimes, it's useful to set HTTP headers:
115
116 http://127.0.0.1:5984/> Accept: application/json
117 http://127.0.0.1:5984/> X-Lodge: black
118
119 These headers are sent with all requests in this session. To see all active headers,
2eb3f4c @kindy61 update README match .command form
kindy61 authored
120 run the `.headers` command:
d304a58 Initial commit.
cloudhead authored
121
2eb3f4c @kindy61 update README match .command form
kindy61 authored
122 http://127.0.0.1:5984/> .headers
d304a58 Initial commit.
cloudhead authored
123 Accept: application/json
124 X-Lodge: black
125
126 Removing headers is just as easy:
127
128 http://127.0.0.1:5984/> Accept:
2eb3f4c @kindy61 update README match .command form
kindy61 authored
129 http://127.0.0.1:5984/> .headers
d304a58 Initial commit.
cloudhead authored
130 X-Lodge: black
131
0b07809 (doc) updated README
cloudhead authored
132 Because JSON is such a common data format, http-console has a way to automatically set
133 the `Content-Type` header to `application/json`. Just pass the `--json` option when
9b3f9a5 Fix typo.
Charles Strahan authored
134 starting http-console, or run the `.json` command:
0b07809 (doc) updated README
cloudhead authored
135
136 $ http-console 127.0.0.1:5984 --json
2eb3f4c @kindy61 update README match .command form
kindy61 authored
137 http://127.0.0.1:5984/> .headers
0b07809 (doc) updated README
cloudhead authored
138 Accept: */*
139 Content-Type: application/json
140
29a1cb3 (doc) updated README
cloudhead authored
141 ### cookies #
142
143 You can enable cookie tracking with the `--cookies` option flag.
2eb3f4c @kindy61 update README match .command form
kindy61 authored
144 To see what cookies are stored, use the `.cookies` command.
29a1cb3 (doc) updated README
cloudhead authored
145
146 ### SSL #
147
27ebaab (doc) updated README
cloudhead authored
148 To enable SSL, pass the `--ssl` flag, or specify the address with `https`.
29a1cb3 (doc) updated README
cloudhead authored
149
d304a58 Initial commit.
cloudhead authored
150 ### quitting #
151
2eb3f4c @kindy61 update README match .command form
kindy61 authored
152 http://127.0.0.1:5984/> .q
d304a58 Initial commit.
cloudhead authored
153
154 nuff' said.
155
156
157
Something went wrong with that request. Please try again.