You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

min-request

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

min-request - npm Package Compare versions

Comparing version
1.1.0
to
1.2.0
+1
.travis.yml
language: node_js
+10
-2
{
"name": "min-request",
"version": "1.1.0",
"version": "1.2.0",
"main": "request.js",

@@ -14,3 +14,11 @@ "scripts": {

"http"
]
],
"repository": {
"type": "git",
"url": "https://github.com/chunpu/min-request.git"
},
"bugs": {
"url": "https://github.com/chunpu/min-request/issues"
},
"homepage": "https://github.com/chunpu/min-request"
}
min-request
===
[![build status][travis-image]][travis-url]
For people who cannot understand [request](https://github.com/request/request) like me to use request
Support string, json, stream, buffer
===
Install

@@ -14,4 +22,39 @@ ---

request(url, [options], callback)
callback param is like `request@request`: err, res, body
Simplest
```js
var request = require('min-request')
request('localhost:8080/test', function(err, res, body) {
console.log(err, body)
})
```
Request with data like json, stream
```js
var request = require('min-request')
// json
request('localhost:8080/upload', {
method: 'POST',
body: {foo: 'bar'}
},function(err, res, body) {
// ...
})
// stream
var fs = require('fs')
request('localhost:8080/upload', {
method: 'POST',
body: fs.createReadStream('./foo.bar')
}, function(err, res, body) {
// ...
})
```
[travis-image]: https://img.shields.io/travis/chunpu/min-request.svg?style=flat
[travis-url]: https://travis-ci.org/chunpu/min-request
+6
-2

@@ -22,3 +22,2 @@ var http = require('http')

hostname: parsed.hostname
, method: opt.method || 'GET'
, port: parsed.port

@@ -28,6 +27,8 @@ , path: parsed.path

}
var body = opt.body
var method = 'GET'
var body = opt.body || opt.data
var type, len
if (null != body) {
// string, buffer, stream, object
method = 'POST'
if (Buffer.isBuffer(body)) {

@@ -52,2 +53,3 @@ type = 'bin'

options.headers = headers
options.method = opt.method || method
var req = http.request(options, function(res) {

@@ -62,2 +64,3 @@ var body = ''

}).on('error', cb)
if (body) {

@@ -70,3 +73,4 @@ if (canPipe(body)) {

}
req.end()
}