Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
curlrequest
Advanced tools
curlrequest is a node wrapper for the command line curl(1)
$ npm install curlrequest
Make a request with curl - callback receives (stderr, stdout)
on request
completion
curl.request(options, callback)
Note that you can also call curl.request(url, callback)
which is
shorthand for curl.request({ url: url }, callback)
.
To setup default options and return a function that can be used later
var request = curl.request(default_options)
request([options ,] callback)
url
The request url.
encoding - default: utf8
Encode the response body as either utf
or ascii
. Set to null
return a
buffer.
headers - default: {}
Set request headers, e.g. headers: { accept: 'text/*' }
useragent - default:
Set the request user-agent.
location - default: true
Whether to follow 30x redirects or not.
redirects - default: 3
The maximum amount of redirects to follow before failing with "retries".
retries - default: 0
How many times to retry the request in the case of failure.
timeout - default: false
The maximum amount of seconds the request can take before failing with error "timeout".
scope - default: {}
The scope to call the callback in.
require - default: null
Pass a string or regular expression to search for in the response body. If there's no match, fail the request with "required string not found". You can also pass an array of strings / regexps to search for where only one has to match.
process - default: false
Pass in a function which modifies the response body before sending it to the callback. Useful if you need to modify the response in some way before a higher level library has the chance to modify it.
Any additional options are sent as command line options to curl. See man curl
or curl --manual
for a detailed description of options and usage.
Example 1. Include response headers in the output
var options = { url: 'google.com', include: true }
curl.request(options, function (err, parts) {
parts = parts.split('\r\n')
var data = parts.pop()
, head = parts.pop()
})
Example 2. Limit the download speed of a transfer
var options = {
url: 'example.com/some/large/file.zip'
, 'limit-rate': '500k'
, encoding: null
}
curl.request(options, function (err, file) {
//file is a Buffer
})
FAQs
A curl wrapper for node
The npm package curlrequest receives a total of 2,112 weekly downloads. As such, curlrequest popularity was classified as popular.
We found that curlrequest demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.