http-headers
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -78,3 +78,5 @@ 'use strict' | ||
function firstLine (str) { | ||
return str.slice(0, str.indexOf('\r\n')) | ||
var nl = str.indexOf('\r\n') | ||
if (nl === -1) return str | ||
else return str.slice(0, nl) | ||
} | ||
@@ -81,0 +83,0 @@ |
{ | ||
"name": "http-headers", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Parse http headers", | ||
@@ -14,7 +14,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"next-line": "^1.0.0" | ||
"next-line": "^1.1.0" | ||
}, | ||
"devDependencies": { | ||
"standard": "^5.1.1", | ||
"tape": "^4.2.0" | ||
"safe-buffer": "^5.1.1", | ||
"standard": "^10.0.2", | ||
"tape": "^4.7.0" | ||
}, | ||
@@ -38,5 +39,5 @@ "keywords": [ | ||
"coordinates": [ | ||
55.687709, | ||
12.5955128 | ||
55.6757062, | ||
12.5774478 | ||
] | ||
} |
@@ -29,3 +29,3 @@ # http-headers | ||
connection: 'keep-alive', | ||
'transfer-Encoding': 'chunked' | ||
'transfer-encoding': 'chunked' | ||
} | ||
@@ -135,3 +135,3 @@ } | ||
connection: 'keep-alive', | ||
'transfer-Encoding': 'chunked' | ||
'transfer-encoding': 'chunked' | ||
} | ||
@@ -164,3 +164,3 @@ } | ||
connection: 'keep-alive', | ||
'transfer-Encoding': 'chunked' | ||
'transfer-encoding': 'chunked' | ||
} | ||
@@ -179,3 +179,3 @@ } | ||
connection: 'keep-alive', | ||
'transfer-Encoding': 'chunked' | ||
'transfer-encoding': 'chunked' | ||
} | ||
@@ -203,3 +203,3 @@ ``` | ||
connection: 'keep-alive', | ||
'transfer-Encoding': 'chunked' | ||
'transfer-encoding': 'chunked' | ||
} | ||
@@ -206,0 +206,0 @@ ``` |
31
test.js
@@ -5,2 +5,3 @@ 'use strict' | ||
var http = require('http') | ||
var Buffer = require('safe-buffer').Buffer | ||
var httpHeaders = require('./') | ||
@@ -82,2 +83,32 @@ | ||
test('request-line only', function (t) { | ||
var requestResult = { | ||
method: 'GET', | ||
url: '/foo', | ||
version: { major: 1, minor: 1 }, | ||
headers: {} | ||
} | ||
t.deepEqual(httpHeaders(requestLine + '\r\n'), requestResult) | ||
t.deepEqual(httpHeaders(new Buffer(requestLine + '\r\n')), requestResult) | ||
t.deepEqual(httpHeaders(requestLine + '\r\n', true), {}) | ||
t.deepEqual(httpHeaders(new Buffer(requestLine + '\r\n'), true), {}) | ||
t.end() | ||
}) | ||
test('status-line only', function (t) { | ||
var responseResult = { | ||
version: { major: 1, minor: 1 }, | ||
statusCode: 200, | ||
statusMessage: 'OK', | ||
headers: {} | ||
} | ||
t.deepEqual(httpHeaders(statusLine + '\r\n'), responseResult) | ||
t.deepEqual(httpHeaders(new Buffer(statusLine + '\r\n')), responseResult) | ||
t.deepEqual(httpHeaders(statusLine + '\r\n', true), {}) | ||
t.deepEqual(httpHeaders(new Buffer(statusLine + '\r\n'), true), {}) | ||
t.end() | ||
}) | ||
test('headers only', function (t) { | ||
@@ -84,0 +115,0 @@ t.deepEqual(httpHeaders(msgHeaders), headerResult) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15045
263
3
6
Updatednext-line@^1.1.0