{"_id":"handy-http","_rev":"2770785","name":"handy-http","description":"Simple wrapper for native NodeJS http[s].request","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"dimik","email":"dimik@yandex.ru"}],"time":{"modified":"2022-05-23T09:39:06.000Z","created":"2014-01-26T16:22:51.641Z","1.0.2":"2015-08-05T07:25:54.782Z","1.0.1":"2015-03-20T16:20:50.082Z","1.0.0":"2014-01-26T16:22:51.641Z"},"users":{},"author":{"name":"Dmitry Poklonskiy"},"repository":{"type":"git","url":"git://github.com/dimik/node-handy-http.git"},"versions":{"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","size":5166,"noattachment":false,"key":"/handy-http/-/handy-http-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/handy-http/download/handy-http-1.0.2.tgz"},"publish_time":1438759554782,"_hasShrinkwrap":false,"_cnpm_publish_time":1438759554782,"_cnpmcore_publish_time":"2021-12-17T01:06:43.466Z"},"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","size":5133,"noattachment":false,"key":"/handy-http/-/handy-http-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/handy-http/download/handy-http-1.0.1.tgz"},"publish_time":1426868450082,"_hasShrinkwrap":false,"_cnpm_publish_time":1426868450082,"_cnpmcore_publish_time":"2021-12-17T01:06:43.662Z"},"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","size":5145,"noattachment":false,"key":"/handy-http/-/handy-http-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/handy-http/download/handy-http-1.0.0.tgz"},"_from":".","_npmVersion":"1.3.25","_npmUser":{"name":"dimik","email":"dimik@yandex.ru"},"maintainers":[{"name":"dimik","email":"dimik@yandex.ru"}],"publish_time":1390753371641,"_hasShrinkwrap":false,"_cnpm_publish_time":1390753371641,"_cnpmcore_publish_time":"2021-12-17T01:06:43.862Z"}},"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","_attachments":{},"homepage":"https://github.com/dimik/node-handy-http#readme","bugs":{"url":"https://github.com/dimik/node-handy-http/issues"},"license":"BSD-2-Clause"}