Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

request-libcurl

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-libcurl - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

26

index.js

@@ -167,2 +167,8 @@ 'use strict';

if (libcurl.pipeTo) {
curl.on('data', (data) => {
libcurl.pipeTo.write(data);
});
}
curl.on('end', (statusCode, body, _headers) => {

@@ -174,2 +180,5 @@ libcurl._debug('[END EVENT]', opts.retries, url.href, finished, statusCode);

finished = true;
if (libcurl.pipeTo) {
libcurl.pipeTo.end();
}
curl.close();

@@ -307,3 +316,3 @@

this.stopRequestTimeout = () => {
this._stopRequestTimeout = () => {
if (this.timeoutTimer) {

@@ -341,4 +350,14 @@ clearTimeout(this.timeoutTimer);

pipe(writableStream) {
if (writableStream.write && writableStream.end) {
this.pipeTo = writableStream;
} else {
throw new TypeError('[request-libcurl] [.pipe()] method accepts only {stream.Writable}');
}
return this;
}
onData(callback) {
this.onData = callback;
return this;
}

@@ -348,2 +367,3 @@

this.onHeader = callback;
return this;
}

@@ -382,3 +402,3 @@

this.finished = true;
this.stopRequestTimeout();
this._stopRequestTimeout();
if (error) {

@@ -408,3 +428,3 @@ this.cb(error);

this._debug('[abort]', this.opts.uri || this.opts.url);
this.stopRequestTimeout();
this._stopRequestTimeout();

@@ -411,0 +431,0 @@ if (this.retryTimer) {

3

package.json
{
"name": "request-libcurl",
"version": "2.1.0",
"version": "2.2.0",
"description": "Extremely stable HTTP request module built on top of libcurl",

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

"http",
"http2",
"https",

@@ -21,0 +22,0 @@ "post",

@@ -26,2 +26,3 @@ # Request-libcurl

- 🎒 Send GET/POST with custom `body` and headers;
- 🗂 Pipe to the file;
- 🚦 Follow or deny redirects;

@@ -45,2 +46,3 @@ - 📤 [Upload files with a single line](https://github.com/VeliovGroup/request-extra#file-upload);

- [POST (*advanced*)](https://github.com/VeliovGroup/request-extra#post-request-with-extra-options)
- [File download via `.pipe()`](https://github.com/VeliovGroup/request-extra#file-download)
- [File upload](https://github.com/VeliovGroup/request-extra#file-upload)

@@ -345,2 +347,28 @@ - [File upload (*multipart*)](https://github.com/VeliovGroup/request-extra#file-upload-multipartform-data)

### File download
Download a file to the FileSystem using `.pipe()` method:
```js
const fs = require('fs');
const request = require('request-libcurl');
const req = request({
url: 'https://example.com/file.pdf',
wait: true
}, (error, resp) => {
if (error) {
throw error;
} else {
// File successfully downloaded
fs.stat('/path/to/file.pdf', (error, stats) => {
// do something with downloaded file
});
}
});
req.pipe(fs.createWriteStream('/path/to/file.pdf', {flags: 'w'}));
req.send();
```
### File upload

@@ -347,0 +375,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