client-http
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -18,1 +18,4 @@ # Changelog | ||
- enhancement: let you read response header in callback | ||
- 0.0.6 (02/04/2014) | ||
- enhancement: Allow set proxy manually by call setProxy |
@@ -9,5 +9,9 @@ 'use strict'; | ||
var _cookie = {}; | ||
var _proxy; | ||
exports.request = httpRequest; | ||
exports.get = httpGet; | ||
exports.request = httpRequest; | ||
exports.get = httpGet; | ||
exports.setProxy = function(proxy){ | ||
_proxy = proxy; | ||
} | ||
@@ -120,3 +124,3 @@ function httpRequest(rawUrl, callback, data, headers){ // data and custom header parameter is optional | ||
} | ||
var proxy = getProxyFromEnv(); | ||
var proxy = getProxy(); | ||
if (target.protocol==="http:"){ | ||
@@ -148,5 +152,11 @@ result.port = target.port ? target.port : 80; | ||
function getProxyFromEnv(){ | ||
if (process.env.http_proxy){ | ||
var proxy = url.parse(process.env.http_proxy); | ||
function getProxy(){ | ||
var proxy; | ||
if (_proxy){ | ||
proxy = _proxy; | ||
}else if (process.env.http_proxy){ | ||
proxy = process.env.http_proxy; | ||
} | ||
proxy = proxy ? url.parse(proxy) : null; | ||
if (proxy && proxy.host){ | ||
return { | ||
@@ -153,0 +163,0 @@ host: proxy.port ? proxy.host.replace(":"+proxy.port, "") : proxy.host, |
{ | ||
"name": "client-http", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Node client HTTP/HTTPS request wrapper for easy to make client HTTP/HTTPS request", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,3 +5,3 @@ # node-client-http: Easy to make client HTTP/HTTPS request | ||
1. Automatic proxy setting, if you set the proxy in your environment variable(http_proxy), it will be auto detected and used in your any HTTP request, also it will be used in your HTTPS request by HTTPS Tunnel(denpency by node-tunnel) to make HTTPS request through HTTP. | ||
1. Automatic proxy setting, if you set the proxy in your environment variable(http_proxy), it will be auto detected and used in your any HTTP request, also it will be used in your HTTPS request by HTTPS Tunnel(denpency by node-tunnel) to make HTTPS request through HTTP. Optional, you can set proxy manually by call setProxy(proxy). | ||
@@ -66,1 +66,10 @@ 2. Make your HTTP/HTTPS request with cookie, cookie will be automatic processed int any HTTP/HTTPS request and you can get the cookie value in response. | ||
}, null, {"User-Agent": "iPhone"}); | ||
### HTTP request with manually proxy set | ||
var http = require('client-http'); | ||
http.setProxy('http://127.0.0.1:8080'); | ||
http.get("https://www.google.com/", function(data){ | ||
data && console.log(data); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9980
14
198
74