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

httplease

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httplease - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2-beta1

test/integration/longStackTraces.spec.js

27

lib/makeRequest.js

@@ -95,15 +95,26 @@ 'use strict';

function waitForResponseHandler(requestConfig, httpResponse) {
return new Promise((resolve, reject) => {
try {
const wrappedResponse = new WrappedResponse(httpResponse, requestConfig.responseBufferSize);
if (requestConfig.responseValidator(wrappedResponse)) {
requestConfig.responseHandler(wrappedResponse)
.then(resolve, reject);
return requestConfig.responseHandler(wrappedResponse);
} else {
requestConfig.errorResponseHandler(wrappedResponse)
.then((response) => throwResponseError(requestConfig, response))
.catch(reject);
return requestConfig.errorResponseHandler(wrappedResponse)
.then((response) => throwResponseError(requestConfig, response));
}
});
} catch (err) {
return Promise.reject(err);
}
}
function supportLongStackTracesWithQ(err) {
// Q needs some help to make the stack trace longer because the callback in
// makeRequest below, httpRequest.on('response'), is not linked to the original
// promise chain.
// See https://github.com/kriskowal/q/blob/ee2b09274e2b03a6fe729efc53b44a71ee75b735/q.js#L381
err.stack = err.stack.replace('From previous event:', 'From older previous event:');
throw err;
}
function makeRequest(requestConfig) {

@@ -122,5 +133,5 @@ return new Promise((resolve, reject) => {

requestConfig.sendRequestFn(httpRequest);
});
}).catch(supportLongStackTracesWithQ);
}
module.exports = makeRequest;
{
"name": "httplease",
"version": "0.3.1",
"version": "0.3.2-beta1",
"description": "HTTP client library with support for pluggable filters, including Zipkin, ASAP, etc",

@@ -45,4 +45,5 @@ "main": "index.js",

"jasmine-promise-tools": "^1.0.0",
"proxyquire": "^1.7.4"
"proxyquire": "^1.7.4",
"q": "^1.4.1"
}
}

@@ -23,4 +23,4 @@ 'use strict';

.withMethodGet()
.withParams({param: 'param'})
.withHeaders({custom: 'header'})
.withParams({param: 'param value, with "special chars&foo=bar!"'})
.withHeaders({custom: 'header with "special chars!"'})
.send()

@@ -30,4 +30,4 @@ .then((result) => {

const args = httpSpy.getHandler.calls.argsFor(0)[0];
expect(args.query).toEqual({param: 'param'});
expect(args.headers.custom).toBe('header');
expect(args.query).toEqual({param: 'param value, with "special chars&foo=bar!"'});
expect(args.headers.custom).toBe('header with "special chars!"');
expect(result.statusCode).toBe(200);

@@ -34,0 +34,0 @@ expect(result.body).toEqual({some: 'body'});

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