Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
HTTP client library with support for pluggable filters, including Zipkin, ASAP, etc
Features:
Existing filters:
Filters that are coming soon!
Possible future filters:
Install the library:
npm install --save httplease
For more examples have a look at the test/integration
directory.
const httplease = require('httplease');
// this can be saved and reused as many times as you want
const httpClient = httplease.builder()
.withBaseUrl('http://example.com/basePath')
.withExpectStatus([200, 204])
.withBufferJsonResponseHandler()
.withTimeout(10000)
.withAgentOptions({keepAlive: true});
// make a request
httpClient
.withPath('/post')
.withJsonBody({someValue: 'some value'})
.withHeaders({'Cookie': 'key=value'})
.withMethodPost()
.send()
.then((response) => {
console.log(response.statusCode);
console.log('get header', response.getHeader('Some-Header'));
console.log('all headers', response.headers);
console.log('JSON body parsing by default', response.body);
})
.catch((err) => {
if (err instanceof httplease.errors.UnexpectedHttpResponseCodeError) {
// the response status check failed
console.log(err.response.statusCode);
console.log(err.response.headers);
console.log(err.response.body);
}
// some unknown error
throw err;
});
You can mix/match the builder style with params in send()
httplease.builder()
.withBufferJsonResponseHandler()
.withExpectStatus([200])
.send({
baseUrl: 'http://example.com/resource',
method: 'POST',
headers: {'Cookie': 'key=value'}
})
.then((response) => {
console.log('response complete');
});
httplease.builder()
.withMethodPost()
.withPath('http://example.com/upload-file')
.withHeaders({'Content-Type': 'application/json'})
.withStreamBody(fs.createReadStream('bigdata.json'))
.withDiscardBodyResponseHandler()
.withExpectStatus([200])
.send()
.then((response) => {
console.log('upload complete!');
});
httplease.builder()
.withMethodGet()
.withPath('http://example.com/')
.withExpectStatus([200])
.withTimeout(1000)
.withResponseHandler((response) => response.pipe(process.stdout))
.send()
.then((response) => {
console.log('download complete!');
});
npm install
# Run all checks
npm test
# Run just the jasmine tests
npm run test:jasmine
# Run just the linter
npm run test:lint
npm version 99.98.97
npm publish
git push
git push --tags
Pull requests, issues and comments welcome. For pull requests:
See the existing issues for things to start contributing.
For bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change.
Atlassian requires contributors to sign a Contributor License Agreement, known as a CLA. This serves as a record stating that the contributor is entitled to contribute the code/documentation/translation to the project and is willing to have it used in distributions and derivative works (or is willing to transfer ownership).
Copyright (c) 2016 Atlassian and others. Apache 2.0 licensed, see LICENSE file.
FAQs
HTTP client library with support for pluggable filters, including Zipkin, ASAP, etc
The npm package httplease receives a total of 1,666 weekly downloads. As such, httplease popularity was classified as popular.
We found that httplease demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.