{ "_args": [ [ { "raw": "httpreq@>=0.4.22", "scope": null, "escapedName": "httpreq", "name": "httpreq", "rawSpec": ">=0.4.22", "spec": ">=0.4.22", "type": "range" }, "/Users/fzy/project/koa2_Sequelize_project/node_modules/httpntlm" ] ], "_from": "httpreq@>=0.4.22", "_id": "httpreq@0.4.24", "_inCache": true, "_location": "/httpreq", "_nodeVersion": "6.9.1", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/httpreq-0.4.24.tgz_1498854530181_0.7929337220266461" }, "_npmUser": { "name": "samdecrock", "email": "sam.decrock@gmail.com" }, "_npmVersion": "3.10.8", "_phantomChildren": {}, "_requested": { "raw": "httpreq@>=0.4.22", "scope": null, "escapedName": "httpreq", "name": "httpreq", "rawSpec": ">=0.4.22", "spec": ">=0.4.22", "type": "range" }, "_requiredBy": [ "/httpntlm" ], "_resolved": "https://registry.npmjs.org/httpreq/-/httpreq-0.4.24.tgz", "_shasum": "4335ffd82cd969668a39465c929ac61d6393627f", "_shrinkwrap": null, "_spec": "httpreq@>=0.4.22", "_where": "/Users/fzy/project/koa2_Sequelize_project/node_modules/httpntlm", "author": { "name": "Sam Decrock", "url": "https://github.com/SamDecrock/" }, "bugs": { "url": "https://github.com/SamDecrock/node-httpreq/issues" }, "contributors": [ { "name": "Russell Beattie", "email": "russ@russellbeattie.com", "url": "https://github.com/russellbeattie" }, { "name": "Jason Prickett MSFT", "url": "https://github.com/jpricketMSFT" }, { "url": "https://github.com/jjharriso" }, { "name": "Sam", "url": "https://github.com/SamDecrock" }, { "name": "MJJ", "url": "https://github.com/mjj2000" }, { "name": "Jeff Young", "url": "https://github.com/jeffyoung" }, { "name": "Dave Preston", "url": "https://github.com/davepreston" }, { "name": "Franklin van de Meent", "email": "fr@nkl.in", "url": "https://github.com/fvdm" } ], "dependencies": {}, "description": "node-httpreq is a node.js library to do HTTP(S) requests the easy way", "devDependencies": { "chai": "~1.9.1", "express": "3.0.3", "mocha": "~1.20.1" }, "directories": {}, "dist": { "shasum": "4335ffd82cd969668a39465c929ac61d6393627f", "tarball": "https://registry.npmjs.org/httpreq/-/httpreq-0.4.24.tgz" }, "engines": { "node": ">= 0.8.0" }, "gitHead": "a48045e87f378079f4e83ed18d6032292cb4a854", "homepage": "https://github.com/SamDecrock/node-httpreq#readme", "license": "MIT", "main": "./lib/httpreq", "maintainers": [ { "name": "samdecrock", "email": "sam.decrock@gmail.com" } ], "name": "httpreq", "optionalDependencies": {}, "readme": "node-httpreq\n============\n\nnode-httpreq is a node.js library to do HTTP(S) requests the easy way\n\nDo GET, POST, PUT, PATCH, DELETE, OPTIONS, upload files, use cookies, change headers, ...\n\n## Install\n\nYou can install __httpreq__ using the Node Package Manager (npm):\n\n npm install httpreq\n\n## Simple example\n```js\nvar httpreq = require('httpreq');\n\nhttpreq.get('http://www.google.com', function (err, res){\n if (err) return console.log(err);\n\n console.log(res.statusCode);\n console.log(res.headers);\n console.log(res.body);\n console.log(res.cookies);\n});\n```\n\n## How to use\n\n* [httpreq.get(url, [options], callback)](#get)\n* [httpreq.post(url, [options], callback)](#post)\n* [httpreq.put(url, [options], callback)](#put)\n* [httpreq.delete(url, [options], callback)](#delete)\n* [httpreq.options(url, [options], callback)](#options)\n* [Uploading files](#upload)\n* [Downloading a binary file](#binary)\n* [Downloading a file directly to disk](#download)\n* [Sending a custom body](#custombody)\n* [Using a http(s) proxy](#proxy)\n* [httpreq.doRequest(options, callback)](#dorequest)\n\n---------------------------------------\n### httpreq.get(url, [options], callback)\n<a name=\"get\"></a>\n\n__Arguments__\n - url: The url to connect to. Can be http or https.\n - options: (all are optional) The following options can be passed:\n - parameters: an object of query parameters\n - headers: an object of headers\n - cookies: an array of cookies\n - auth: a string for basic authentication. For example `username:password`\n - binary: true/false (default: false), if true, res.body will a buffer containing the binary data\n - allowRedirects: (default: __true__ , only with httpreq.get() ), if true, redirects will be followed\n - maxRedirects: (default: __10__ ). For example 1 redirect will allow for one normal request and 1 extra redirected request.\n - timeout: (default: __none__ ). Adds a timeout to the http(s) request. Should be in milliseconds.\n - proxy, if you want to pass your request through a http(s) proxy server:\n - host: eg: \"192.168.0.1\"\n - port: eg: 8888\n - protocol: (default: __'http'__ ) can be 'http' or 'https'\n - rejectUnauthorized: validate certificate for request with HTTPS. [More here](http://nodejs.org/api/https.html#https_https_request_options_callback)\n - callback(err, res): A callback function which is called when the request is complete. __res__ contains the headers ( __res.headers__ ), the http status code ( __res.statusCode__ ) and the body ( __res.body__ )\n\n__Example without options__\n\n```js\nvar httpreq = require('httpreq');\n\nhttpreq.get('http://www.google.com', function (err, res){\n if (err) return console.log(err);\n\n console.log(res.statusCode);\n console.log(res.headers);\n console.log(res.body);\n});\n```\n\n__Example with options__\n\n```js\nvar httpreq = require('httpreq');\n\nhttpreq.get('http://posttestserver.com/post.php', {\n parameters: {\n name: 'John',\n lastname: 'Doe'\n },\n headers:{\n 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:18.0) Gecko/20100101 Firefox/18.0'\n },\n cookies: [\n 'token=DGcGUmplWQSjfqEvmu%2BZA%2Fc',\n 'id=2'\n ]\n}, function (err, res){\n if (err){\n console.log(err);\n }else{\n console.log(res.body);\n }\n});\n```\n---------------------------------------\n### httpreq.post(url, [options], callback)\n<a name=\"post\"></a>\n\n__Arguments__\n - url: The url to connect to. Can be http or https.\n - options: (all are optional) The following options can be passed:\n - parameters: an object of post parameters (content-type is set to *application/x-www-form-urlencoded; charset=UTF-8*)\n - json: if you want to send json directly (content-type is set to *application/json*)\n - files: an object of files to upload (content-type is set to *multipart/form-data; boundary=xxx*)\n - body: custom body content you want to send. If used, previous options will be ignored and your custom body will be sent. (content-type will not be set)\n - headers: an object of headers\n - cookies: an array of cookies\n - auth: a string for basic authentication. For example `username:password`\n - binary: true/false (default: __false__ ), if true, res.body will be a buffer containing the binary data\n - allowRedirects: (default: __false__ ), if true, redirects will be followed\n - maxRedirects: (default: __10__ ). For example 1 redirect will allow for one normal request and 1 extra redirected request.\n - encodePostParameters: (default: __true__ ), if true, POST/PUT parameters names will be URL encoded.\n - timeout: (default: none). Adds a timeout to the http(s) request. Should be in milliseconds.\n - proxy, if you want to pass your request through a http(s) proxy server:\n - host: eg: \"192.168.0.1\"\n - port: eg: 8888\n - protocol: (default: __'http'__ ) can be 'http' or 'https'\n - rejectUnauthorized: validate certificate for request with HTTPS. [More here](http://nodejs.org/api/https.html#https_https_request_options_callback)\n - callback(err, res): A callback function which is called when the request is complete. __res__ contains the headers ( __res.headers__ ), the http status code ( __res.statusCode__ ) and the body ( __res.body__ )\n\n__Example without extra options__\n\n```js\nvar httpreq = require('httpreq');\n\nhttpreq.post('http://posttestserver.com/post.php', {\n parameters: {\n name: 'John',\n lastname: 'Doe'\n }\n}, function (err, res){\n if (err){\n console.log(err);\n }else{\n console.log(res.body);\n }\n});\n```\n\n__Example with options__\n\n```js\nvar httpreq = require('httpreq');\n\nhttpreq.post('http://posttestserver.com/post.php', {\n parameters: {\n name: 'John',\n lastname: 'Doe'\n },\n headers:{\n 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:18.0) Gecko/20100101 Firefox/18.0'\n },\n cookies: [\n 'token=DGcGUmplWQSjfqEvmu%2BZA%2Fc',\n 'id=2'\n ]\n}, function (err, res){\n if (err){\n console.log(err);\n }else{\n console.log(res.body);\n }\n});\n```\n\n---------------------------------------\n### httpreq.put(url, [options], callback)\n<a name=\"put\"></a>\n\nSame options as [httpreq.post(url, [options], callback)](#post)\n\n---------------------------------------\n<a name=\"delete\" />\n### httpreq.delete(url, [options], callback)\n\nSame options as [httpreq.post(url, [options], callback)](#post)\n\n---------------------------------------\n<a name=\"options\" />\n### httpreq.options(url, [options], callback)\n\nSame options as [httpreq.get(url, [options], callback)](#get) except for the ability to follow redirects.\n\n---------------------------------------\n<a name=\"upload\" />\n### Uploading files\n\nYou can still use ```httpreq.uploadFiles({url: 'url', files: {}}, callback)```, but it's easier to just use POST (or PUT):\n\n__Example__\n\n```js\nvar httpreq = require('httpreq');\n\nhttpreq.post('http://posttestserver.com/upload.php', {\n parameters: {\n name: 'John',\n lastname: 'Doe'\n },\n files:{\n myfile: __dirname + \"/testupload.jpg\",\n myotherfile: __dirname + \"/testupload.jpg\"\n }\n}, function (err, res){\n if (err) throw err;\n});\n```\n\n---------------------------------------\n<a name=\"binary\"></a>\n### Downloading a binary file\nTo download a binary file, just add __binary: true__ to the options when doing a get or a post.\n\n__Example__\n\n```js\nvar httpreq = require('httpreq');\n\nhttpreq.get('https://ssl.gstatic.com/gb/images/k1_a31af7ac.png', {binary: true}, function (err, res){\n if (err){\n console.log(err);\n }else{\n fs.writeFile(__dirname + '/test.png', res.body, function (err) {\n if(err)\n console.log(\"error writing file\");\n });\n }\n});\n```\n\n---------------------------------------\n<a name=\"download\"></a>\n### Downloading a file directly to disk\nTo download a file directly to disk, use the download method provided.\n\nDownloading is done using a stream, so the data is not stored in memory and directly saved to file.\n\n__Example__\n\n```js\nvar httpreq = require('httpreq');\n\nhttpreq.download(\n 'https://ssl.gstatic.com/gb/images/k1_a31af7ac.png',\n __dirname + '/test.png'\n, function (err, progress){\n if (err) return console.log(err);\n console.log(progress);\n}, function (err, res){\n if (err) return console.log(err);\n console.log(res);\n});\n\n```\n---------------------------------------\n<a name=\"custombody\"></a>\n### Sending a custom body\nUse the body option to send a custom body (eg. an xml post)\n\n__Example__\n\n```js\nvar httpreq = require('httpreq');\n\nhttpreq.post('http://posttestserver.com/post.php',{\n body: '<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\n headers:{\n 'Content-Type': 'text/xml',\n }},\n function (err, res) {\n if (err){\n console.log(err);\n }else{\n console.log(res.body);\n }\n }\n);\n```\n\n---------------------------------------\n<a name=\"proxy\"></a>\n### Using a http(s) proxy\n\n__Example__\n\n```js\nvar httpreq = require('httpreq');\n\nhttpreq.post('http://posttestserver.com/post.php', {\n proxy: {\n host: '10.100.0.126',\n port: 8888\n }\n}, function (err, res){\n if (err){\n console.log(err);\n }else{\n console.log(res.body);\n }\n});\n```\n\n---------------------------------------\n### httpreq.doRequest(options, callback)\n<a name=\"dorequest\"></a>\n\nhttpreq.doRequest is internally used by httpreq.get() and httpreq.post(). You can use this directly. Everything is stays the same as httpreq.get() or httpreq.post() except that the following options MUST be passed:\n- url: the url to post the files to\n- method: 'GET', 'POST', 'PUT' or 'DELETE'\n\n## Donate\n\nIf you like this module or you want me to update it faster, feel free to donate. It helps increasing my dedication to fixing bugs :-)\n\n[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AB3R2SUL53K7S)\n\n\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git://github.com/SamDecrock/node-httpreq.git" }, "scripts": {}, "version": "0.4.24" }