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.2.9 to 0.3.0

History.md

41

lib/urllib.js

@@ -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

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