{"_id":"handy-http","_rev":"6-60a8421d4f8384a86b1c82fd0655fbfc","name":"handy-http","description":"Simple wrapper for native NodeJS http[s].request","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"handy-http","version":"1.0.0","description":"Simple wrapper for native NodeJS http[s].request","main":"index.js","directories":{"test":"test"},"scripts":{"test":"nodeunit test"},"repository":{"type":"git","url":"git://github.com/dimik/node-handy-http.git"},"keywords":["http","https"],"author":{"name":"Dmitry Poklonskiy"},"license":"BSD-2-Clause","bugs":{"url":"https://github.com/dimik/node-handy-http/issues"},"homepage":"https://github.com/dimik/node-handy-http","_id":"handy-http@1.0.0","dist":{"shasum":"7def8d5c43de736c2b3513abdc26ffea422f697f","tarball":"https://registry.npmjs.org/handy-http/-/handy-http-1.0.0.tgz","integrity":"sha512-vBZNEc903hGphOfDhDdOukqfJFrzfUeiEKZtWDULZw6kb4uI2IwDaDJThfirPXdTe610Iv/Wmslu3YeAcWIBsg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDC/RV+Nu9Gbbl8/vpnDwJWHR1frS747/rIgG/mthLlJQIgDLhHdTOImk+9MuIodjYqxBBwO0i89NxdNlvYifiMhaY="}]},"_from":".","_npmVersion":"1.3.25","_npmUser":{"name":"dimik","email":"dimik@yandex.ru"},"maintainers":[{"name":"dimik","email":"dimik@yandex.ru"}]},"1.0.1":{"name":"handy-http","version":"1.0.1","description":"Simple wrapper for native NodeJS http[s].request","main":"index.js","directories":{"test":"test"},"scripts":{"test":"nodeunit test"},"repository":{"type":"git","url":"git://github.com/dimik/node-handy-http.git"},"keywords":["http","https"],"author":{"name":"Dmitry Poklonskiy"},"license":"BSD-2-Clause","bugs":{"url":"https://github.com/dimik/node-handy-http/issues"},"gitHead":"5e68b149549e9367a25eec0df0357ff62009603b","homepage":"https://github.com/dimik/node-handy-http","_id":"handy-http@1.0.1","_shasum":"0a31d2ba66cd1b0d96115fc69db17b116411ad03","_from":".","_npmVersion":"2.7.3","_nodeVersion":"0.12.0","_npmUser":{"name":"dimik","email":"dimik@yandex.ru"},"maintainers":[{"name":"dimik","email":"dimik@yandex.ru"}],"dist":{"shasum":"0a31d2ba66cd1b0d96115fc69db17b116411ad03","tarball":"https://registry.npmjs.org/handy-http/-/handy-http-1.0.1.tgz","integrity":"sha512-NbnY+RdFOmcYqWcvFVe4MMbSSeL9Jx16KVAsddXHT5MC7HDrkArGg6IXZgcZniaCGbqTqZfWI4VK9P9cP3+ySw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDH+m5qiNGvQh3gSD8czRdfgrs5jdErJJrwPi+Fga9aKgIhAM9MMHrV+GGJtcQ/Uhyy4YGQBPsUytzQFqvrfaaxDqpN"}]}},"1.0.2":{"name":"handy-http","version":"1.0.2","description":"Simple wrapper for native NodeJS http[s].request","main":"index.js","directories":{"test":"test"},"scripts":{"test":"nodeunit test"},"repository":{"type":"git","url":"git://github.com/dimik/node-handy-http.git"},"keywords":["http","https"],"author":{"name":"Dmitry Poklonskiy"},"license":"BSD-2-Clause","bugs":{"url":"https://github.com/dimik/node-handy-http/issues"},"gitHead":"5b9663508851fc7fd05696ecb33fc4b1ece11759","homepage":"https://github.com/dimik/node-handy-http#readme","_id":"handy-http@1.0.2","_shasum":"24860dca376a69fbb7cd1a604a221e2a56639126","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.12.5","_npmUser":{"name":"dimik","email":"dimik@yandex.ru"},"maintainers":[{"name":"dimik","email":"dimik@yandex.ru"}],"dist":{"shasum":"24860dca376a69fbb7cd1a604a221e2a56639126","tarball":"https://registry.npmjs.org/handy-http/-/handy-http-1.0.2.tgz","integrity":"sha512-UC5vCmXTu7+vEh2MzJQaNjHFu07CUniCvitrURw8y+ns2kHDCjen9HIQQfNamMM86GTPOchXR8LfOuVTE8u/AQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAqa2fhLqDG+PgiKZfo5RT3r7DplE6/v7wkuRfrosEvfAiADWEr4pBRgINGwCvZYeYuLgIR9+Wr1Akn3mkl4w5GDNQ=="}]}}},"readme":"NodeJS handy http[s] client\n============\n\nHandy-http module provides simple and flexible interface for NodeJS native <a htref=\"http://nodejs.org/api/http.html#http_http_request_options_callback\">http.request<a>.\n\nDescription\n============\n\nThis class is very lightweight and handful if you need to make various types of http requests with just a few lines of code.\nIn my projects it lets me to avoid copy-pasting and makes my code more readable and maintainable.\nClass provides 'open' method that takes a connection object as the first param and a callback function as the second one.\nIt returns the request object that can be listened to all kinds of events from original NodeJS <a href=\"http://nodejs.org/api/http.html#http_class_http_clientrequest\">http.ClientRequest</a>.\nMain features:\n- accepts various types of data to send from plain javascript objects to NodeJS Buffer and ReadableStream.\n- is able to send multiple files with 'multipart/form-data' Content-Type header\n- returns parsed JSON object if server respond with properly Content-Type header\n- supports proxy requests\n- provides ability to extend request headers\n- supports https protocol\n\nExample\n------------\n```javascript\nvar HTTPClient = require('handy-http'),\n    client = new HTTPCLient(),\n    onResponse = function (err, res) {\n        console.log(err || res);\n    };\n\n/**\n * The simplest case is the 'GET' request'.\n */\nclient.open('http://_url_', onResponse);\n\n// It is shortcut for\nclient.open({ url: 'http://_url_' }, onResponse);\n\n/**\n * You can combine url params in querystring with a hash of additional params\n * It's not nessesary urlencode your params first, it will be done for you.\n */\nclient.open({\n    url: 'http://_url_?one=1&two=2',\n    data: { three: 3, more: '4 and 5' }\n}, onResponse);\n// Resulting URL will look like http://_url_?one=1&two=2&three=3&more=4%20and%205'\n\n/**\n * Your should note 'POST' or any connection method if you want that type of request.\n */\nclient.open({\n    url: 'http://_url_',\n    method: 'POST',\n    data: { param1: 'value1', param2: 'value2' }\n}, onResponse);\n\n/**\n * You can send a file or any binary data within request using NodeJS Buffer as data value.\n * You can also use NodeJS <a href=\"http://nodejs.org/api/stream.html\">Stream-like</a> object, for example <a href=\"http://nodejs.org/api/fs.html#fs_class_fs_readstream\">fs.ReadStream</a>\n * Stream will be sent by chunks with 'Transfer-Encoding: chunked' HTTP-header\n */\nvar fileStream = fs.createReadStream('_path_to_file_'),\n    fileBuffer = fs.readFileSync('_path_to_file_');\n\nclient.open({\n    url: 'http://_url_',\n    method: 'POST',\n    data: fileBuffer,\n    // data: fileStream // wil be sended with 'Transfer-Encoding: chunked' HTTP-header,\n    headers: {\n        'content-type': 'application/octet-stream'\n    }\n}, onResponse);\n\n/**\n * You can send some files and additional data with 'multipart/form-data' Content-Type header.\n */\nclient.open({\n    url: 'http://_url_',\n    method: 'POST',\n    data: { param1: 'value1', param2: 'value2' },\n    files: [\n        { fieldname: 'fileField1', name: 'test.png', type: 'image/png', value: file1Buffer },\n        { fieldname: 'fileField2', name: 'test.jpg', type: 'image/jpeg', value: file2Buffer }\n    ],\n    headers {\n        'content-type': 'multipart/form-data'\n    }\n}, onResponse);\n\n/**\n * You can proxy your request.\n */\nclient.open({\n    url: 'http://_url_',\n    method: 'POST',\n    data: { param1: 'value1', param2: 'value2' },\n    proxy: {\n        host: '_proxy_host_',\n        port: '_proxy_port_'\n    }\n}, onResponse);\n\n/**\n * If you need a lower level of manipulation you can still listen to all events provided by native NodeJS <a href=\"http://nodejs.org/api/http.html#http_class_http_clientrequest\">http.ClientRequest</a>.\n */\nvar request = client.open(...);\n\nrequest.on('socket', function (socket) {\n    ...\n});\n\n// You can close connection if you need it.\nrequest.close();\n\n```\n","maintainers":[{"name":"dimik","email":"dimik@yandex.ru"}],"time":{"modified":"2022-06-18T18:56:42.917Z","created":"2014-01-26T16:22:51.641Z","1.0.0":"2014-01-26T16:22:51.641Z","1.0.1":"2015-03-20T16:20:50.082Z","1.0.2":"2015-08-05T07:25:54.782Z"},"readmeFilename":"README.md","homepage":"https://github.com/dimik/node-handy-http#readme","keywords":["http","https"],"repository":{"type":"git","url":"git://github.com/dimik/node-handy-http.git"},"author":{"name":"Dmitry Poklonskiy"},"bugs":{"url":"https://github.com/dimik/node-handy-http/issues"},"license":"BSD-2-Clause"}