diff --git a/lib/main.js b/lib/main.js index fa3633f..dfe3ee0 100644 --- a/lib/main.js +++ b/lib/main.js @@ -242,7 +242,7 @@ http.post('http://localhost/post?param1=value1&param2=value2', function (err // explicit POST request, saves the response body to file -// for Buffer reqBody, the content-lenght header is reqBody.lenght +// for Buffer reqBody, the content-length header is reqBody.length var reqBody = { param1: 'value1', param2: 'value2' @@ -363,7 +363,7 @@ http.put({ // pipe a HTTP response (a http.IncomingMessage Object) to a PUT request // http-request knows how to handle an IncomingMessage -// content-lenght is taken from the response if exists +// content-length is taken from the response if exists require('http').get('http://example.org/file.ext', function (im) { http.put({ url: 'http://localhost/put', @@ -388,7 +388,7 @@ http.put({ url: 'http://localhost/put', reqBody: readableStream, headers: { - 'content-lenght': 1337, + 'content-length': 1337, 'content-type': 'text/plain' } }, 'put.bin', function (err, res) { diff --git a/lib/request.js b/lib/request.js index ed68cef..e7287b2 100644 --- a/lib/request.js +++ b/lib/request.js @@ -763,7 +763,7 @@ module.exports = Request; * @property {Boolean} noSslValidation Optional; turns of the SSL validation. **Warning:** do this only if you know what you're doing and if you have proper reasons for doing it. Making SSL useless is not a small thing to do * @property {Boolean} stream Optional; passes a ReadableStream back to the completion callback of a HTTP request * @property {Boolean} noRedirect Optional; turns off the HTTP redirects. Passes back the headers and body of the redirect response. Adds a couple of response headers which indicate the redirection target: redirect-to-url - which indicates the target URL for the redirect as the location header might be a relative path, and redirect-to-host if there's a specified host header in the request - * @property {Buffer|Stream} reqBody Optional; the contents of the request body for PUT, POST, etc. requests. Must be a Buffer or a Readable Stream instance. For Buffers, the content-length is Buffer.lenght. For a Readable Stream you must pass a content-length header, unless you're building a POST request with the [form-data](https://github.com/felixge/node-form-data) module. The library makes no assumptions about the content-type header, unless you're building a form with form-data + * @property {Buffer|Stream} reqBody Optional; the contents of the request body for PUT, POST, etc. requests. Must be a Buffer or a Readable Stream instance. For Buffers, the content-length is Buffer.length. For a Readable Stream you must pass a content-length header, unless you're building a POST request with the [form-data](https://github.com/felixge/node-form-data) module. The library makes no assumptions about the content-type header, unless you're building a form with form-data * @property {Object} auth Optional; an Object that contains the authentication information. Currently it only implements HTTP Basic Authentication. The HTTP Basic Authentication was already supported by passing the username:password to the URL itself. This option provides a more API-friendly approach and it adds the basics for implementing HTTP Digest Authentication. * @property {String} auth.type The authentication type; Supported value: basic * @property {String} auth.username The HTTP Authentication username diff --git a/test/get.test.js b/test/get.test.js index a7d5160..eb1f0f4 100644 --- a/test/get.test.js +++ b/test/get.test.js @@ -283,7 +283,7 @@ describe('HTTP GET method tests', function() { assert.isNull(err, 'we have an error'); assert.strictEqual(res.code, 206, 'we have the proper status code'); - assert.isDefined(res.headers['content-length'], 'we have a Content-Lenght'); + assert.isDefined(res.headers['content-length'], 'we have a Content-Length'); assert.strictEqual(res.headers['content-range'], '0-5/11', 'we have the proper value for the Content-Range response header'); assert.strictEqual(res.headers['x-http-method'], 'GET', 'the method is GET');