1
- http-browserify
2
- ===============
1
+ # http-browserify
3
2
4
3
The
5
4
[ http] ( http://nodejs.org/docs/v0.4.10/api/all.html#hTTP ) module from node.js,
@@ -9,10 +8,9 @@ When you `require('http')` in
9
8
[ browserify] ( http://github.com/substack/node-browserify ) ,
10
9
this module will be loaded.
11
10
12
- example
13
- =======
11
+ # example
14
12
15
- ```` javascript
13
+ ``` js
16
14
var http = require (' http' );
17
15
18
16
http .get ({ path : ' /beep' }, function (res ) {
@@ -27,15 +25,13 @@ http.get({ path : '/beep' }, function (res) {
27
25
div .innerHTML += ' <br>__END__' ;
28
26
});
29
27
});
30
- ````
28
+ ```
31
29
32
- http methods
33
- ============
30
+ # http methods
34
31
35
32
var http = require('http');
36
33
37
- var req = http.request(options, cb)
38
- -----------------------------------
34
+ ## var req = http.request(options, cb)
39
35
40
36
` options ` can have:
41
37
@@ -47,68 +43,50 @@ var req = http.request(options, cb)
47
43
48
44
The callback will be called with the response object.
49
45
50
- var req = http.get(options, cb)
51
- -------------------------------
46
+ ## var req = http.get(options, cb)
52
47
53
48
A shortcut for
54
49
55
- ```` javascript
50
+ ``` js
56
51
options .method = ' GET' ;
57
52
var req = http .request (options, cb);
58
53
req .end ();
59
- ````
54
+ ```
60
55
61
- request methods
62
- ===============
56
+ # request methods
63
57
64
- req.setHeader(key, value)
65
- -------------------------
58
+ ## req.setHeader(key, value)
66
59
67
60
Set an http header.
68
61
69
- req.getHeader(key)
70
- -------------------------
62
+ ## req.getHeader(key)
71
63
72
64
Get an http header.
73
65
74
- req.removeHeader(key)
75
- -------------------------
66
+ ## req.removeHeader(key)
76
67
77
68
Remove an http header.
78
69
79
- req.write(data)
80
- ---------------
70
+ ## req.write(data)
81
71
82
72
Write some data to the request body.
83
73
84
- req.end(data)
85
- -------------
74
+ ## req.end(data)
86
75
87
76
Close and send the request body, optionally with additional ` data ` to append.
88
77
89
- response methods
90
- ================
78
+ # response methods
91
79
92
- res.getHeader(key)
93
- ------------------
80
+ ## res.getHeader(key)
94
81
95
82
Return an http header, if set. ` key ` is case-insensitive.
96
83
97
- response attributes
98
- ===================
84
+ # response attributes
99
85
100
86
* res.statusCode, the numeric http response code
101
87
* res.headers, an object with all lowercase keys
102
88
103
- response events
104
- ---------------
105
-
106
- * data
107
- * end
108
- * error
109
-
110
- compatibility
111
- =============
89
+ # compatibility
112
90
113
91
This module has been tested and works with:
114
92
@@ -123,8 +101,7 @@ and are somewhat buffered in Opera. In all the other browsers you get a nice
123
101
unbuffered stream of ` "data" ` events when you send down a content-type of
124
102
` multipart/octet-stream ` or similar.
125
103
126
- protip
127
- ======
104
+ # protip
128
105
129
106
You can do:
130
107
@@ -136,3 +113,15 @@ var bundle = browserify({
136
113
137
114
in order to map "http-browserify" over ` require('http') ` in your browserified
138
115
source.
116
+
117
+ # install
118
+
119
+ With [ npm] ( https://npmjs.org ) do:
120
+
121
+ ```
122
+ npm install http-browserify
123
+ ```
124
+
125
+ # license
126
+
127
+ MIT
0 commit comments