Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

httpreq

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpreq - npm Package Compare versions

Comparing version 0.2.9 to 0.3.0

31

httpreq.js

@@ -65,13 +65,24 @@ /*

var reqUrl = url.parse(o.url);
var path = reqUrl.path;
var port;
var host;
var path;
var isHttps = false;
if(reqUrl.port){
port = reqUrl.port;
}else if(reqUrl.protocol == 'https:'){
port = 443;
if(o.proxy){
port = o.proxy.port;
host = o.proxy.host;
path = o.url; // complete url
if(o.proxy.protocol && o.proxy.protocol.match(/https/)) isHttps = true;
}else{
port = 80;
var reqUrl = url.parse(o.url);
host = reqUrl.hostname;
path = reqUrl.path;
if(reqUrl.protocol == 'https:') isHttps = true;
if(reqUrl.port){
port = reqUrl.port;
}else if(isHttps){
port = 443;
}else{
port = 80;
}
}

@@ -90,3 +101,3 @@

var requestoptions = {
host: reqUrl.hostname,
host: host,
port: port,

@@ -159,3 +170,3 @@ path: path,

if(reqUrl.protocol == 'https:')
if(isHttps)
request = https.request(requestoptions, requestResponse);

@@ -162,0 +173,0 @@ else

{
"name": "httpreq",
"description": "node-httpreq is a node.js library to do HTTP(S) requests the easy way",
"version": "0.2.9",
"version": "0.3.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Sam Decrock",

@@ -22,2 +22,3 @@ node-httpreq

* [Sending a custom body](#custombody)
* [Using a http(s) proxy](#proxy)

@@ -39,2 +40,6 @@ ---------------------------------------

- timeout: (default: none). Adds a timeout to the http(s) request. Should be in milliseconds.
- proxy (optional) if you want to pass your request through a http(s) proxy server:
- host: the host of the proxy, eg: "192.168.0.1"
- port: eg: 8888
- protocol: (optional, default: 'http') can be 'http' or 'https'
- 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__ )

@@ -97,2 +102,6 @@

- timeout: (default: none). Adds a timeout to the http(s) request. Should be in milliseconds.
- proxy (optional) if you want to pass your request through a http(s) proxy server:
- host: the host of the proxy, eg: "192.168.0.1"
- port: eg: 8888
- protocol: (optional, default: 'http') can be 'http' or 'https'
- 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__ )

@@ -196,2 +205,6 @@

- timeout: (default: none). Adds a timeout to the http(s) request. Should be in milliseconds.
- proxy (optional) if you want to pass your request through a http(s) proxy server:
- host: the host of the proxy, eg: "192.168.0.1"
- port: eg: 8888
- protocol: (optional, default: 'http') can be 'http' or 'https'
- 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__ )

@@ -267,2 +280,25 @@

---------------------------------------
<a name="proxy" />
### Using a http(s) proxy
__Example__
```js
var httpreq = require('httpreq');
httpreq.post('http://posttestserver.com/post.php', {
proxy: {
host: '10.100.0.126',
port: 8888
}
}, function (err, res){
if (err){
console.log(err);
}else{
console.log(res.body);
}
});
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc