Skip to content

yosriady/curl-to-har

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

Thanks

curl-to-har © 2016+, Yos Riady. Released under the MIT License.
Authored and maintained by Yos Riady with help from contributors (list).

yos.io  ·  GitHub @yosriady

About

Convert curl commands to HAR request objects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published