New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cheerio-httpcli

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cheerio-httpcli - npm Package Compare versions

Comparing version 0.3.6 to 0.3.7

test/maxdatasize.js

8

CHANGELOG.md

@@ -0,4 +1,10 @@

# 0.3.7 (2015-11-15)
* 受信サイズ制限オプション(maxDataSize)追加(#8)
* フォーム送信時のパラメータ名がURLエンコードされていなかったのを修正
* 不必要な空GETパラメータが入ってフォーム送信が上手く行かないケースを修正
# 0.3.6 (2015-11-08)
* 生DOM要素から作成したcheerioオブジェクトでclickやsubmitがエラーになっていたのを修正
* 生DOM要素から作成したcheerioオブジェクトでclickやsubmitがエラーになっていたのを修正(#7)

@@ -5,0 +11,0 @@ # 0.3.5 (2015-11-03)

6

lib/cheerio-extend.js

@@ -144,6 +144,6 @@ /*eslint no-invalid-this:0*/

var fp = formParam[p];
var pstr = '';
for (var i = 0; i < fp.length; i++) {
var escval = encoding.escape(doc.encoding, fp[i] != null ? fp[i] : '');
formParamStr += '&' + p + '=' + escval;
var escName = encoding.escape(doc.encoding, p);
var escVal = encoding.escape(doc.encoding, fp[i] != null ? fp[i] : '');
formParamStr += '&' + escName + '=' + escVal;
}

@@ -150,0 +150,0 @@ });

@@ -126,4 +126,9 @@ /*eslint key-spacing:0, no-undefined:0*/

// レスポンスのサイズを計測するためのバッファ
var buffer = '';
var maxDataSize = this.core.maxDataSize;
// リクエスト実行
request(param, (function (err, res, body) {
var req = request(param, (function (err, res, body) {
if (err) {

@@ -165,3 +170,14 @@ return callback(err, res, body);

}
}).bind(this));
}).bind(this)).on('data', function(chunk) {
if (maxDataSize !== null) {
// バッファにチャンクを追加
buffer += chunk;
// 制限を超過したら中止
if (buffer.length > maxDataSize) {
req.abort();
return callback(new Error('data size limit over'));
}
}
});
},

@@ -291,3 +307,5 @@

};
options.param[(method === 'GET') ? 'qs' : 'form'] = param;
if (Object.keys(param || {}).length > 0) {
options.param[(method === 'GET') ? 'qs' : 'form'] = param;
}

@@ -294,0 +312,0 @@ return options;

@@ -24,2 +24,3 @@ /*eslint key-spacing:0*/

debug : false, // デバッグオプション
maxDataSize : null, // 受信を許可する最大のサイズ

@@ -26,0 +27,0 @@ /**

{
"name": "cheerio-httpcli",
"version": "0.3.6",
"version": "0.3.7",
"description": "http client module with cheerio & iconv(-lite) & promise",

@@ -32,3 +32,3 @@ "main": "index.js",

"scripts": {
"test": "istanbul cover ./node_modules/mocha/bin/_mocha -x lib/vendor/** -x index.js && true || true",
"test": "istanbul cover ./node_modules/mocha/bin/_mocha -x lib/vendor/** -x index.js && true || true",
"lint": "eslint test/*.js lib/*.js example/*.js && true || true",

@@ -35,0 +35,0 @@ "cs": "jscs test lib example && true || true"

@@ -105,2 +105,9 @@ var nstatic = require('node-static');

file.serveFile('/error/404.html', 404, {}, req, res);
} else if (/~mega/.test(req.url)) {
// 巨大サイズ
res.writeHead(200);
var buf = new Array(1024 * 1024).join().split(',').map(function (v, i, a) {
return 'a';
}).join('');
res.end(buf);
} else {

@@ -107,0 +114,0 @@ // 通常HTMLファイル

@@ -254,3 +254,3 @@ /*eslint-env mocha*/

it('checkbox要素を含んだフォームのcheckedがフォーム送信パラメータのデフォルトになっている', function (done) {
var param = '?check1=1&check2=&check3=&check4%5B0%5D=';
var param = '?check1=1&check2=&check3=&check4%5B%5D=';
cli.fetch(helper.url('form', 'utf-8'), function (err, $, res, body) {

@@ -257,0 +257,0 @@ $('form[name=checkbox]').submit(function (err, $, res, body) {

@@ -228,3 +228,3 @@ /*eslint-env mocha*/

assert(err instanceof Error);
assert.deepEqual(Object.keys(err).sort(), [ 'param', 'response', 'statusCode', 'url' ]);
assert.deepEqual(Object.keys(err).sort(), [ 'response', 'statusCode', 'url' ]);
assert(err.message === 'no content');

@@ -231,0 +231,0 @@ assert(err.statusCode === 404);

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