Miss any of our Open RFC calls?Watch the recordings here! »

curl-to-har

1.0.1 • Public • Published

curl-to-har

curl-to-har converts shell curl commands to HAR request objects:

curl --request POST --url 'http://mockbin.com/request?foo=bar&foo=baz' --header 'accept: application/json' --header 'content-type: application/json' --cookie 'foo=bar; bar=baz' --data '{"foo": "bar"}'
 
{ 
  method: 'POST',
  url: 'http://mockbin.com/request',
  httpVersion: 'HTTP/1.1',
  queryString: [ { name: 'foo', value: 'bar' }, { name: 'foo', value: 'baz' } ],
  headers: 
   [ { name: 'accept', value: 'application/json' },
     { name: 'content-type', value: 'application/json' } ],
  cookies: [ { name: 'foo', value: 'bar' }, { name: 'bar', value: 'baz' } ],
  postData: { mimeType: 'application/json', text: { foo: 'bar' } } 
}

Usage

npm install curl-to-har
var curlToHar = require('curl-to-har');
var curlString = "curl --request POST --url 'http://mockbin.com/request?foo=bar&foo=baz' --header 'accept: application/json' --header 'content-type: application/json' --cookie 'foo=bar; bar=baz' --data '{\"foo\": \"bar\"}'"
var HAR = curlToHAR(input)

console.log(HAR);

Running tests

npm test

For more usage examples, check out the test directory.

-- For any errors, please submit an issue here. Pull requests are most welcome!

Install

npm i curl-to-har

DownloadsWeekly Downloads

9

Version

1.0.1

License

MIT

Last publish

Collaborators

  • avatar