Comparing version 0.2.9 to 0.3.0
@@ -50,2 +50,3 @@ /** | ||
* - {Agent} [httpsAgent]: optional, https agent | ||
* - {String} auth: Basic authentication i.e. 'user:password' to compute an Authorization header. | ||
* @param {Function} callback, callback(error, data, res) | ||
@@ -84,2 +85,8 @@ * @param {Object} optional context of callback, callback.call(context, error, data, res) | ||
}; | ||
if (info.auth) { | ||
options.auth = info.auth; | ||
} | ||
if (args.auth) { | ||
options.auth = args.auth; | ||
} | ||
var body = args.content || args.data; | ||
@@ -165,35 +172,1 @@ if (!args.content) { | ||
}; | ||
/** | ||
* guest data charset from req.headers and html content-type meta tag | ||
* headers: | ||
* 'content-type': 'text/html;charset=gbk' | ||
* meta tag: | ||
* {meta http-equiv="Content-Type" content="text/html; charset=xxxx"/} | ||
* | ||
* @param {Object} res | ||
* @param {Buffer} data | ||
* @return {String} charset (lower case, eg: utf-8, gbk, gb2312, ...) | ||
* If can\'t guest, return null | ||
* @api public | ||
*/ | ||
exports.getCharset = function getCharset(res, data) { | ||
var CHARTSET_RE = /charset=([\w\-]+)/ig; | ||
var matchs = null; | ||
var end = data.length > 512 ? 512 : data.length; | ||
// console.log(data.toString()) | ||
var content_type = res.headers['content-type']; | ||
if (content_type) { | ||
// guest from header first | ||
matchs = CHARTSET_RE.exec(content_type); | ||
} | ||
if (!matchs) { | ||
// guest from html header | ||
content_type = data.slice(0, end).toString(); | ||
matchs = CHARTSET_RE.exec(content_type); | ||
} | ||
if (matchs) { | ||
return matchs[1].toLowerCase(); | ||
} | ||
return null; | ||
}; |
{ | ||
"name": "urllib", | ||
"version": "0.2.9", | ||
"description": "Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more. Like python's _urllib_ module.", | ||
"version": "0.3.0", | ||
"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" ], | ||
@@ -6,0 +6,0 @@ "author": "fengmk2 <fengmk2@gmail.com> (http://github.com/fengmk2)", |
@@ -1,7 +0,9 @@ | ||
# urllib | ||
# urllib [![Build Status](https://secure.travis-ci.org/TBEDP/urllib.png?branch=master)](http://travis-ci.org/TBEDP/urllib) | ||
[![Build Status](https://secure.travis-ci.org/TBEDP/urllib.png?branch=master)](http://travis-ci.org/TBEDP/urllib) | ||
![logo](https://raw.github.com/TBEDP/urllib/master/logo.png) | ||
Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more. Like python _urllib_ module. | ||
Help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, redirections, cookies and more. | ||
jscoverage: [100%](http://fengmk2.github.com/coverage/urllib.html) | ||
## Install | ||
@@ -15,4 +17,2 @@ | ||
### urllib.request() | ||
``` | ||
@@ -30,5 +30,4 @@ var urllib = require('urllib'); | ||
* Upload file. | ||
* Upload file like form upload. | ||
* Auto redirect handle. | ||
* Bash auth support. | ||
@@ -35,0 +34,0 @@ ## Authors |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
0
3
10023
9
162
78