Socket
Socket
Sign inDemoInstall

http-string-parser

Package Overview
Dependencies
0
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

test/fixtures/get/response-string-304

11

lib/parser.js

@@ -29,2 +29,3 @@ // Generated by CoffeeScript 1.6.3

parsedStatusLine = parseStatusLine(lines.shift());
response['protocolVersion'] = parsedStatusLine['protocol'];
response['statusCode'] = parsedStatusLine['statusCode'];

@@ -59,7 +60,9 @@ response['statusMessage'] = parsedStatusLine['statusMessage'];

var parsed, parts;
parts = statusLine.split(' ');
parts = statusLine.match(/^(.+) ([0-9]{3}) (.*)$/);
parsed = {};
parsed['protocol'] = parts[0];
parsed['statusCode'] = parts[1];
parsed['statusMessage'] = parts[2];
if (parts !== null) {
parsed['protocol'] = parts[1];
parsed['statusCode'] = parts[2];
parsed['statusMessage'] = parts[3];
}
return parsed;

@@ -66,0 +69,0 @@ };

{
"name": "http-string-parser",
"version": "0.0.4",
"version": "0.0.5",
"description": "Parse HTTP Request and Response from String",

@@ -5,0 +5,0 @@ "main": "lib/parser.js",

@@ -7,12 +7,13 @@ # http-string-parser

Parse HTTP message (Request and Response) from raw string in Node.JS
Parse HTTP messages (Request and Response) from raw string in Node.JS
##Parse HTTP Message
##Parse HTTP Messages
```javascript
var parser = require('http-string-parser');
message = parser.parse(string);
request = parser.parseRequest(requestString);
response = parser.parseResponse(responseString);
console.log(message['request']);
console.log(message['response']);
console.log(request);
console.log(response);
```

@@ -35,6 +36,7 @@

`praseHeaders(headersLinesArray)`
`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)
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)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc