Socket
Socket
Sign inDemoInstall

urllib

Package Overview
Dependencies
Maintainers
1
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

urllib - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

6

History.md
0.4.2 / 2013-08-10
==================
* fix SELF_SIGNED_CERT_IN_CHAIN test case on node 0.8 and 0.6
* [√] https & self-signed certificate
0.4.1 / 2013-08-05

@@ -3,0 +9,0 @@ ==================

40

lib/urllib.js

@@ -58,5 +58,18 @@ /**

* - {Number} [timeout]: request timeout(in milliseconds), default is `exports.TIMEOUT`
* - {Agent} [agent]: optional, http agent
* - {Agent} [httpsAgent]: optional, https agent
* - {String} auth: Basic authentication i.e. 'user:password' to compute an Authorization header.
* - {Agent} [agent]: optional, http agent. Set `false` if you does not use agent.
* - {Agent} [httpsAgent]: optional, https agent. Set `false` if you does not use agent.
* - {String} [auth]: Basic authentication i.e. 'user:password' to compute an Authorization header.
* - {String|Buffer|Array} [ca]: An array of strings or Buffers of trusted certificates.
* If this is omitted several well known "root" CAs will be used, like VeriSign.
* These are used to authorize connections.
* Notes: This is necessary only if the server uses the self-signed certificate
* - {Boolean} [rejectUnauthorized]: If true, the server certificate is verified against the list of supplied CAs.
* An 'error' event is emitted if verification fails. Default: true.
* - {String|Buffer} [pfx]: A string or Buffer containing the private key,
* certificate and CA certs of the server in PFX or PKCS12 format.
* - {String|Buffer} [key]: A string or Buffer containing the private key of the client in PEM format.
* Notes: This is necessary only if using the client certificate authentication
* - {String|Buffer} [cert]: A string or Buffer containing the certificate key of the client in PEM format.
* Notes: This is necessary only if using the client certificate authentication
* - {String} [passphrase]: A string of passphrase for the private key or pfx.
* @param {Function} callback, callback(error, data, res)

@@ -83,5 +96,9 @@ * @param {Object} optional context of callback, callback.call(context, error, data, res)

var agent = args.agent || exports.agent;
if (parsedUrl.protocol === 'https:') {
httplib = https;
agent = args.httpsAgent || exports.httpsAgent;
if (args.httpsAgent === false) {
agent = false;
}
if (!parsedUrl.port) {

@@ -92,2 +109,6 @@ port = 443;

if (args.agent === false) {
agent = false;
}
var options = {

@@ -102,2 +123,14 @@ host: parsedUrl.hostname || parsedUrl.host || 'localhost',

var sslNames = ['ca', 'pfx', 'key', 'cert', 'passphrase'];
for (var i = 0; i < sslNames.length; i++) {
var name = sslNames[i];
if (args[name]) {
options[name] = args[name];
}
}
if (args.rejectUnauthorized !== undefined) {
options.rejectUnauthorized = args.rejectUnauthorized;
}
var auth = args.auth || parsedUrl.auth;

@@ -156,3 +189,2 @@ if (auth) {

var reqId = ++REQUEST_ID;
// make request
var req = httplib.request(options, function (res) {

@@ -159,0 +191,0 @@ if (writeStream) {

12

package.json
{
"name": "urllib",
"version": "0.4.1",
"version": "0.4.2",
"description": "Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more.",
"keywords": [ "urllib", "http", "urlopen", "curl", "wget" ],
"keywords": [ "urllib", "http", "urlopen", "curl", "wget", "request", "https" ],
"author": "fengmk2 <fengmk2@gmail.com> (http://github.com/fengmk2)",

@@ -16,3 +16,3 @@ "homepage": "http://github.com/TBEDP/urllib",

"blanket": { "pattern": "urllib/lib" },
"travis-cov": { "threshold": 98 }
"travis-cov": { "threshold": 100 }
},

@@ -26,2 +26,5 @@ "dependencies": {

"pedding": "*",
"formstream": "*",
"agentkeepalive": "*",
"node-patch": "*",
"blanket": "*",

@@ -31,5 +34,2 @@ "travis-cov": "*",

"mocha-lcov-reporter": "*",
"formstream": "*",
"agentkeepalive": "*",
"node-patch": "*",
"mocha": ">=0.14.1"

@@ -36,0 +36,0 @@ },

@@ -46,8 +46,23 @@ # urllib [![Build Status](https://secure.travis-ci.org/TBEDP/urllib.png?branch=master)](http://travis-ci.org/TBEDP/urllib) [![Coverage Status](https://coveralls.io/repos/TBEDP/urllib/badge.png)](https://coveralls.io/r/TBEDP/urllib)

- ***auth*** String - `username:password` used in HTTP Basic Authorization.
- ***agent*** [http.Agent](http://nodejs.org/api/http.html#http_class_http_agent) - HTTP Agent object.
- ***httpsAgent*** [https.Agent](http://nodejs.org/api/https.html#https_class_https_agent) - HTTPS Agent object.
- ***agent*** [http.Agent](http://nodejs.org/api/http.html#http_class_http_agent) - HTTP Agent object.
Set `false` if you does not use agent.
- ***httpsAgent*** [https.Agent](http://nodejs.org/api/https.html#https_class_https_agent) - HTTPS Agent object.
Set `false` if you does not use agent.
- ***ca*** String | Buffer | Array - An array of strings or Buffers of trusted certificates.
If this is omitted several well known "root" CAs will be used, like VeriSign.
These are used to authorize connections.
**Notes**: This is necessary only if the server uses the self-signed certificate
- ***rejectUnauthorized*** Boolean - If true, the server certificate is verified against the list of supplied CAs.
An 'error' event is emitted if verification fails. Default: true.
- ***pfx*** String | Buffer - A string or Buffer containing the private key,
certificate and CA certs of the server in PFX or PKCS12 format.
- ***key*** String | Buffer - A string or Buffer containing the private key of the client in PEM format.
**Notes**: This is necessary only if using the client certificate authentication
- ***cert*** String | Buffer - A string or Buffer containing the certificate key of the client in PEM format.
**Notes**: This is necessary only if using the client certificate authentication
- ***passphrase*** String - A string of passphrase for the private key or pfx.
- ***callback(err, data, res)*** Function - Optional callback.
- **err** Error - Would be `null` if no error accured.
- **data** Buffer | Object - The data responsed. Would be a Buffer if `dataType` is set to `text` or an JSON parsed into Object if it's set to `json`.
- **res** [stream.Readable](http://nodejs.org/api/stream.html#stream_class_stream_readable) - The response stream.
- **res** [http.IncomingMessage](http://nodejs.org/api/http.html#http_http_incomingmessage) - The response.
- ***context*** Object - Optional context object that will be binded to `this` of `callback`.

@@ -57,3 +72,3 @@

[stream.Writable](http://nodejs.org/api/stream.html#stream_class_stream_writable) - The request stream.
[http.ClientRequest](http://nodejs.org/api/http.html#http_class_http_clientrequest) - The request.

@@ -78,3 +93,3 @@ Calling `.abort()` method of the request stream can cancel the request.

For `POST`, `PATCH` or `PUT` request,
For others like `POST`, `PATCH` or `PUT` request,
in defaults, the `data` will be stringify into `application/x-www-form-urlencoded` format

@@ -157,3 +172,4 @@ if `Content-Type` header is not set.

urllib.request('http://127.0.0.1:1984/socket.end', function (err, data, res) {
should.not.exist(err);
err.name.should.equal('RemoteSocketClosedError');
err.message.should.equal('Remote socket was terminated before `response.end()` was called');
data.toString().should.equal('foo haha\nfoo haha 2');

@@ -170,2 +186,3 @@ should.ok(res.aborted);

* [ ] Auto redirect handle
* [√] https & self-signed certificate

@@ -180,11 +197,11 @@ ## Authors

project : urllib
repo age : 2 years, 2 months
active : 28 days
commits : 71
files : 16
repo age : 2 years, 3 months
active : 32 days
commits : 89
files : 17
authors :
57 fengmk2 80.3%
9 XiNGRZ 12.7%
4 Jackson Tian 5.6%
1 aleafs 1.4%
75 fengmk2 84.3%
9 XiNGRZ 10.1%
4 Jackson Tian 4.5%
1 aleafs 1.1%
```

@@ -191,0 +208,0 @@

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