https://github.com/apiaryio/http-string-parser
Parse HTTP Request and Response from String in Node.JS
https://github.com/apiaryio/http-string-parser
http parser sjs-team
Last synced: 7 months ago
JSON representation
Parse HTTP Request and Response from String in Node.JS
- Host: GitHub
- URL: https://github.com/apiaryio/http-string-parser
- Owner: apiaryio
- License: mit
- Archived: true
- Created: 2013-07-23T09:45:19.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2021-07-26T13:49:00.000Z (over 4 years ago)
- Last Synced: 2025-05-30T00:07:20.655Z (8 months ago)
- Topics: http, parser, sjs-team
- Language: CoffeeScript
- Size: 28.3 KB
- Stars: 26
- Watchers: 14
- Forks: 6
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# http-string-parser
[](https://www.npmjs.com/package/http-string-parser)
[](https://travis-ci.org/apiaryio/http-string-parser)
[](https://david-dm.org/apiaryio/http-string-parser)
[](https://david-dm.org/apiaryio/http-string-parser?type=dev)
Parse HTTP messages (Request and Response) from raw string in Node.JS
## Parse HTTP Messages
```javascript
var parser = require('http-string-parser');
request = parser.parseRequest(requestString);
response = parser.parseResponse(responseString);
console.log(request);
console.log(response);
```
See more about [Request][request] and [Response][response] data model.
[request]: https://www.relishapp.com/apiary/gavel/docs/data-model#http-request
[response]: https://www.relishapp.com/apiary/gavel/docs/data-model#http-response
## API Reference
`parseRequest(requestString)`
`parseRequestLine(requestLine)`
`parseResponse(responseString)`
`parseStatusLine(statusLine)`
`parseHeaders(headersLinesArray)`
- - -
NOTE: Proof of concept, naive HTTP parsing, wheel re-inventation. In future it may be replaced with better parser from [Node.JS core's C bindings of NGINX HTTP parser](https://github.com/joyent/http-parser) or [PEG.js HTTP parser](https://npmjs.org/package/http-pegjs)