diff --git a/doc/api/http.markdown b/doc/api/http.markdown index c0a8730ca9..b0499707c1 100644 --- a/doc/api/http.markdown +++ b/doc/api/http.markdown @@ -489,11 +489,19 @@ upload a file with a POST request, then write to the `ClientRequest` object. Example: + var postData = querystring.stringify({ + 'msg' : 'Hello World!' + }); + var options = { hostname: 'www.google.com', port: 80, path: '/upload', - method: 'POST' + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Length': postData.length + } }; var req = http.request(options, function(res) { @@ -510,8 +518,7 @@ Example: }); // write data to request body - req.write('data\n'); - req.write('data\n'); + req.write(postData); req.end(); Note that in the example `req.end()` was called. With `http.request()` one