1

I was wondering if it is possible to generate cURL string from a libcurl instance. For example if I'm using the node binding for libcurl as below,

const curl = new Curl();
curl.setOpt(Curl.option.URL, "https://httpbin.org/get");

Is it possible to somehow generate the following from this instance?

curl https://httpbin.org/get
scriptonist
  • 697
  • 4
  • 9
  • An alternative approach is to record the full HTTP request that was generated and convert *that* into a curl command line with [h2c](https://curl.haxx.se/h2c/). – Daniel Stenberg Nov 13 '19 at 08:53

1 Answers1

0

This is not possible with libcurl and so it's not possible with the Node.js bindings, node-libcurl.

To do that you will need to create a wrapper around the Curl instance and keep track of the options being set on it, you can then use that information to build the command line arguments.

disclaimer: I'm the author of the node.js bindings

jonathancardoso
  • 11,737
  • 7
  • 53
  • 72