{"id":13468308,"url":"https://github.com/apiaryio/curl-trace-parser","last_synced_at":"2026-01-10T05:13:59.838Z","repository":{"id":9270710,"uuid":"11099872","full_name":"apiaryio/curl-trace-parser","owner":"apiaryio","description":"Parser for output from Curl --trace option","archived":true,"fork":false,"pushed_at":"2021-08-02T13:22:16.000Z","size":94,"stargazers_count":197,"open_issues_count":12,"forks_count":14,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-11-21T11:04:01.759Z","etag":null,"topics":["curl","http","parser","sjs-team","trace"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apiaryio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-01T15:54:52.000Z","updated_at":"2024-11-08T09:04:00.000Z","dependencies_parsed_at":"2022-09-01T05:23:12.355Z","dependency_job_id":null,"html_url":"https://github.com/apiaryio/curl-trace-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiaryio%2Fcurl-trace-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiaryio%2Fcurl-trace-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiaryio%2Fcurl-trace-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apiaryio%2Fcurl-trace-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apiaryio","download_url":"https://codeload.github.com/apiaryio/curl-trace-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227598457,"owners_count":17791605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curl","http","parser","sjs-team","trace"],"created_at":"2024-07-31T15:01:08.527Z","updated_at":"2026-01-10T05:13:59.772Z","avatar_url":"https://github.com/apiaryio.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Dependency intelligence"],"sub_categories":[],"readme":"# The `curl --trace` parser\n\n[![NPM Version](https://img.shields.io/npm/v/curl-trace-parser.svg)](https://www.npmjs.com/package/curl-trace-parser)\n[![Build Status](https://travis-ci.org/apiaryio/curl-trace-parser.svg)](https://travis-ci.org/apiaryio/curl-trace-parser)\n[![Dependency Status](https://david-dm.org/apiaryio/curl-trace-parser.svg)](https://david-dm.org/apiaryio/curl-trace-parser)\n[![devDependency Status](https://david-dm.org/apiaryio/curl-trace-parser/dev-status.svg)](https://david-dm.org/apiaryio/curl-trace-parser?type=dev)\n[![Greenkeeper badge](https://badges.greenkeeper.io/apiaryio/curl-trace-parser.svg)](https://greenkeeper.io/)\n\n\n## The story\n\nDid you know that you can record raw HTTP communication of [Curl command-line tool](http://curl.haxx.se/docs/manpage.html) with the `--trace` and `--trace-ascii` option? It's the only way I know to get raw HTTP communication without using the [`tcpdump`](http://www.tcpdump.org/) or [`wireshark`](http://www.wireshark.org/).\nFor example, this trick is very useful for the proper introspection into HTTP communication of an undocumented RESTful API.\n\nThe only glitch is that cURL `--trace` saves data in [its custom format][gist], far from human-friendly, saving chunks as they are being received and splitting them by packets. If you want a human readable form then this parser is what you need. Delivered as a Node.js package.\n\n[gist]: https://gist.github.com/netmilk/6048533\n\n## Usage\n\n```\n$ curl --trace - http://httpbin.org/ip | curl-trace-parser\n```\n\n## Sample API\n\nWe will be using this [sample API][apiarydoc] created with the [Apiary.io mock server](http://apiary.io) to demonstrate tracing an HTTP communication and the use of the cURL trace parser.\n\n[apiarydoc]: http://docs.curltraceparser.apiary.io/\n\n## Install the cURL trace parser\n\n```bash\n$ npm install -g curl-trace-parser\n```\n\n## Record your first trace file\n\n```bash\n$ curl --trace tracefile --header \"Content-Type: application/json\" \\\n--request POST \\\n--data-binary \"{ \\\"product\\\":\\\"1AB23ORM\\\", \\\"quantity\\\": 2 }\" \\\n\"http://curltraceparser.apiary.io/shopping-cart\"\n```\n\nNote this cURL example is copied and pasted from [Apiary interactive API documentation][example].\n\n[example]: http://docs.curltraceparser.apiary.io/#get-%2Fshopping-cart\n\n## Examples\n\n### `--raw` format\n\nThe output is ASCII representation of a raw [HTTP message][message] with few modifications:\n\n- Request line begins with `\u003e `\n- Response line begins with `\u003c `\n- Request and Response is delimited by CR+LF\n- Both Request and Response are terminated by an extra trailing LF\n\nNote: This is little bit tricky because HTTP RFC does not have declared delimiter for Request and Response, for obvious reasons.\n\n```bash\n$ cat tracefile | curl-trace-parser --raw\n\u003e POST /shopping-cart HTTP/1.1\n\u003e User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8x zlib/1.2.5\n\u003e Host: curltraceparser.apiary.io\n\u003e Accept: */*\n\u003e Content-Type: application/json\n\u003e Content-Length: 39\n\u003e\n\u003e { \"product\":\"1AB23ORM\", \"quantity\": 2 }\n\n\u003c HTTP/1.1 201 Created\n\u003c Content-Type: application/json\n\u003c Date: Tue, 30 Jul 2013 11:32:30 GMT\n\u003c X-Apiary-Ratelimit-Limit: 120\n\u003c X-Apiary-Ratelimit-Remaining: 119\n\u003c Content-Length: 50\n\u003c Connection: keep-alive\n\u003c\n\u003c { \"status\": \"created\", \"url\": \"/shopping-cart/2\" }\n```\n\n### `--blueprint` format\n\nThe output is HTTP Request and Response in the [API blueprint format](http://apiblueprint.org) which is the superset of markdown.\n\n```\n$ cat tracefile | ./bin/curl-trace-parser --blueprint\n# POST /shopping-cart\n+ Request\n    + Headers\n\n            User-Agent:curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8x zlib/1.2.5\n            Host:curltraceparser.apiary.io\n            Accept:*/*\n            Content-Type:application/json\n            Content-Length:39\n\n    + Body\n\n            { \"product\":\"1AB23ORM\", \"quantity\": 2 }\n\n+ Response 201\n    + Headers\n\n            Content-Type:application/json\n            Date:Tue, 30 Jul 2013 11:32:30 GMT\n            X-Apiary-Ratelimit-Limit:120\n            X-Apiary-Ratelimit-Remaining:119\n            Content-Length:50\n            Connection:keep-alive\n\n    + Body\n\n            { \"status\": \"created\", \"url\": \"/shopping-cart/2\" }\n\n```\n\nNote: This format does not expect any CR+LF in the message body\n\n### Parse the trace to raw HTTP file using Node.JS\n\n```javascript\nvar fs = require('fs');\nvar parser = require('curl-trace-parser');\nfs.readFile('./tracefile', 'utf8', function (err,trace) {\n  console.log(parser.parse(trace));\n})\n```\n\n## Output format reverse parser\n\n```javascript\nvar fs = require('fs');\nvar parser = require('curl-trace-parser');\nfs.readFile('./tracefile', 'utf8', function (err,trace) {\n  console.log(parser.parseBack(trace));\n})\n```\n\n## API Reference\n\n`parse(traceString)` - parse string with trace to object with raw request and response\n\n`parseToString(traceString)` - parse string with trace to [output format]\n\n`parseBack(outputString)` - parse string with [output format] back to object with raw request an resposne\n\n\n[output format]: https://github.com/apiaryio/curl-trace-parser#output-format\n[message]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapiaryio%2Fcurl-trace-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapiaryio%2Fcurl-trace-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapiaryio%2Fcurl-trace-parser/lists"}