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

httpism

Package Overview
Dependencies
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpism - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

26

browser.js

@@ -5,2 +5,3 @@ var window = require('global');

var querystringLite = require('./querystring-lite');
var randomString = require('random-string');

@@ -23,2 +24,26 @@ function json(request, next) {

function jsonp(request, next) {
var jsonp = request.options.jsonp;
if (jsonp) {
request.options.querystring = request.options.querystring || {};
var callbackName = randomString({length: 20});
request.options.querystring[jsonp] = callbackName;
var value;
window[callbackName] = function(v) {
value = v;
};
return next().then(function (response) {
eval(response.body);
response.body = value;
delete window[callbackName];
return response;
});
}
return next();
}
function text(request, next) {

@@ -160,2 +185,3 @@ if (typeof request.body === 'string') {

json,
jsonp,
text,

@@ -162,0 +188,0 @@ utils.querystring,

5

package.json
{
"name": "httpism",
"version": "2.1.0",
"version": "2.2.0",
"description": "HTTP client with middleware and good defaults",

@@ -11,2 +11,3 @@ "main": "index.js",

"qs": "^0.6.6",
"random-string": "0.1.2",
"tough-cookie": "2.2.0",

@@ -36,3 +37,3 @@ "underscore": "^1.6.0"

"mock-xhr-router": "1.1.1",
"phantomjs-prebuilt": "2.1.4",
"phantomjs-prebuilt": "2.1.11",
"pogo": "^0.9.6",

@@ -39,0 +40,0 @@ "server-destroy": "1.0.1",

1

readme.md

@@ -241,2 +241,3 @@ # httpism [![npm version](https://img.shields.io/npm/v/httpism.svg)](https://www.npmjs.com/package/httpism) [![npm](https://img.shields.io/npm/dm/httpism.svg)](https://www.npmjs.com/package/httpism) [![Build Status](https://travis-ci.org/featurist/httpism.svg?branch=master)](https://travis-ci.org/featurist/httpism)

Many of these options are ignored by default, so you should set `agent: undefined` to force a new agent to honour the options.
* `jsonp`: to perform a JSONP request, set this to the name of the parameter to contain the callback function, often this is simply `callback`.
* `jsonReviver`: a [reviver function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) that is passed to `JSON.parse(string, [reviver])` to override how JSON response bodies are decoded.

@@ -243,0 +244,0 @@

@@ -54,2 +54,7 @@ var express = require('express');

app.get('/jsonp', function(req, res) {
res.set('Content-Type', 'text/javascript');
res.send(`${req.query.callback}({blah: 'blah'})`);
});
module.exports = app;

@@ -51,3 +51,3 @@ var expect = require('chai').expect;

it('throws if receives 404', function () {
return httpism.get('/status/404').then(function (response) {
return httpism.get('/status/404').then(function () {
throw new Error('expected to throw exception');

@@ -61,2 +61,8 @@ }, function (response) {

});
it('can call JSONP', function () {
return httpism.get('/jsonp', {jsonp: 'callback'}).then(function (response) {
expect(response.body).to.eql({blah: 'blah'});
});
});
});

@@ -63,0 +69,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