JSPM

request2curl

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 332
  • Score
    100M100P100Q88353F
  • License MIT

Convert request(...) options to curl without executing the request

Package Exports

  • request2curl

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (request2curl) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Request2curl - Convert request(...) options to curl without executing the request

Function to convert request options into curl command. Module supports most of the common request options.

var request2curl = require("request2curl");

var options = {
    url: "https://example.com",
    qs: { a: [1,2], b: "text" }
};

var curlCmd = request2curl(options);
// curl 'https://example.com?a%5B0%5D=1&a%5B1%5D=2&b=text' --location --max-redirs 10

request(options, function() { ... })

Install:

npm install request2curl

request.defaults

To use request.defaults pass them manually into request2curl.

var options = { ...  };
var curlCmd = request2curl(options, request.defaults);

Supported options

  • uri||url
  • baseUrl
  • method
  • headers
  • qs
  • qsParseOptions
  • qsStringifyOptions
  • useQuerystring
  • body
  • form
  • formData
  • multipart
  • preampleCRLF
  • postambleCRLF
  • json
  • auth
  • oauth
  • hawk
  • aws
  • httpSignature
  • followRedirect
  • followAllRedirects
  • followOriginalHTTPMethod
  • maxRedirects
  • removeRefererHeader - no analog in curl
  • gzip
  • agentOptions
  • forever
  • timeout
  • localAddress
  • proxy
  • strictSSL
  • tunnel
  • proxyHeaderWhiteList
  • proxyHeaderExclusiveList
  • har