mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Updating node_modules
This commit is contained in:
parent
46c4a8b0cb
commit
1e31d66870
13 changed files with 813 additions and 0 deletions
10
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/.travis.yml
generated
vendored
Normal file
10
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
sudo: false
|
||||
language: node_js
|
||||
node_js:
|
||||
- '8'
|
||||
- '7'
|
||||
- '6'
|
||||
- '5'
|
||||
- '4'
|
||||
- '0.12'
|
||||
- '0.10'
|
21
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/LICENSE
generated
vendored
Normal file
21
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017 Thomas Watson Steen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
205
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/README.md
generated
vendored
Normal file
205
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/README.md
generated
vendored
Normal file
|
@ -0,0 +1,205 @@
|
|||
# http-headers
|
||||
|
||||
[](https://travis-ci.org/watson/http-headers)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
Parse the start-line and headers from an HTTP request or reponse.
|
||||
|
||||
Converts:
|
||||
|
||||
```http
|
||||
HTTP/1.1 200 OK
|
||||
Date: Tue, 10 Jun 2014 07:19:27 GMT
|
||||
Connection: keep-alive
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
Hello World
|
||||
```
|
||||
|
||||
To this:
|
||||
|
||||
```js
|
||||
{
|
||||
version: { major: 1, minor: 1 },
|
||||
statusCode: 200,
|
||||
statusMessage: 'OK',
|
||||
headers: {
|
||||
date: 'Tue, 10 Jun 2014 07:19:27 GMT',
|
||||
connection: 'keep-alive',
|
||||
'transfer-encoding': 'chunked'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Features:**
|
||||
|
||||
- Auto-detects and ignores body if present
|
||||
- Fully [RFC 2068](http://www.rfc-base.org/txt/rfc-2068.txt) compliant
|
||||
(please [open an issue](https://github.com/watson/http-headers/issues)
|
||||
if you find a discrepancy)
|
||||
- Support multi-line headers (lines will be joined with a space)
|
||||
- Support repeating headers
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install http-headers --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var net = require('net')
|
||||
var httpHeaders = require('http-headers')
|
||||
|
||||
// create TCP server
|
||||
net.createServer(function (c) {
|
||||
var buffers = []
|
||||
c.on('data', buffers.push.bind(buffers))
|
||||
c.on('end', function () {
|
||||
var data = Buffer.concat(buffers)
|
||||
|
||||
// parse incoming data as an HTTP request and extra HTTP headers
|
||||
console.log(httpHeaders(data))
|
||||
})
|
||||
}).listen(8080)
|
||||
```
|
||||
|
||||
### `http.ServerReponse` support
|
||||
|
||||
If given an instance of `http.ServerResponse`, the reponse headers is
|
||||
automatically extracted, parsed and returned:
|
||||
|
||||
```js
|
||||
var http = require('http')
|
||||
var httpHeaders = require('http-headers')
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
res.end('Hello World')
|
||||
console.log(httpHeaders(res))
|
||||
}).listen(8080)
|
||||
```
|
||||
|
||||
#### Why?
|
||||
|
||||
If you've ever needed to log or in another way access the headers sent
|
||||
to the client on a `http.ServerResponse` in Node.js, you know it's not
|
||||
as easy as with the `http.IncomingMessage` headers (which you just
|
||||
access via `request.headers['content-type']`).
|
||||
|
||||
Response headers are not directly available on the `response` object.
|
||||
Instead all headers are preprocessed as a string on the private
|
||||
`response._header` property and needs to be processed in order to be
|
||||
available as an object.
|
||||
|
||||
This module makes the task super simple.
|
||||
|
||||
## API
|
||||
|
||||
The http-headers module exposes a single parser function:
|
||||
|
||||
```js
|
||||
httpHeaders(data[, onlyHeaders])
|
||||
```
|
||||
|
||||
Arguments:
|
||||
|
||||
- `data` - A string, buffer or instance of `http.ServerReponse`
|
||||
- `onlyHeaders` - An optional boolean. If `true`, only the headers
|
||||
object will be returned. Defaults to `false`
|
||||
|
||||
### Request example
|
||||
|
||||
If given a request as input:
|
||||
|
||||
```http
|
||||
GET /foo HTTP/1.1
|
||||
Date: Tue, 10 Jun 2014 07:19:27 GMT
|
||||
Connection: keep-alive
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
Hello World
|
||||
```
|
||||
|
||||
Returns:
|
||||
|
||||
```js
|
||||
{
|
||||
method: 'GET',
|
||||
url: '/foo',
|
||||
version: { major: 1, minor: 1 },
|
||||
headers: {
|
||||
date: 'Tue, 10 Jun 2014 07:19:27 GMT',
|
||||
connection: 'keep-alive',
|
||||
'transfer-encoding': 'chunked'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Response example
|
||||
|
||||
If given a request as input:
|
||||
|
||||
```http
|
||||
HTTP/1.1 200 OK
|
||||
Date: Tue, 10 Jun 2014 07:19:27 GMT
|
||||
Connection: keep-alive
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
Hello World
|
||||
```
|
||||
|
||||
Returns:
|
||||
|
||||
```js
|
||||
{
|
||||
version: { major: 1, minor: 1 },
|
||||
statusCode: 200,
|
||||
statusMessage: 'OK',
|
||||
headers: {
|
||||
date: 'Tue, 10 Jun 2014 07:19:27 GMT',
|
||||
connection: 'keep-alive',
|
||||
'transfer-encoding': 'chunked'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `onlyHeaders` example
|
||||
|
||||
If the optional second argument is set to `true`, only headers are
|
||||
returned no matter the type of input:
|
||||
|
||||
```js
|
||||
{
|
||||
date: 'Tue, 10 Jun 2014 07:19:27 GMT',
|
||||
connection: 'keep-alive',
|
||||
'transfer-encoding': 'chunked'
|
||||
}
|
||||
```
|
||||
|
||||
### No Start-Line
|
||||
|
||||
If the `data` given does not contain an HTTP Start-Line, only the
|
||||
headers are returned, even if the `onlyHeaders` argument is `false`:
|
||||
|
||||
```http
|
||||
Date: Tue, 10 Jun 2014 07:19:27 GMT
|
||||
Connection: keep-alive
|
||||
Transfer-Encoding: chunked
|
||||
|
||||
Hello World
|
||||
```
|
||||
|
||||
Returns:
|
||||
|
||||
```js
|
||||
{
|
||||
date: 'Tue, 10 Jun 2014 07:19:27 GMT',
|
||||
connection: 'keep-alive',
|
||||
'transfer-encoding': 'chunked'
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
137
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/index.js
generated
vendored
Normal file
137
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/index.js
generated
vendored
Normal file
|
@ -0,0 +1,137 @@
|
|||
'use strict'
|
||||
|
||||
var nextLine = require('next-line')
|
||||
|
||||
// RFC-2068 Start-Line definitions:
|
||||
// Request-Line: Method SP Request-URI SP HTTP-Version CRLF
|
||||
// Status-Line: HTTP-Version SP Status-Code SP Reason-Phrase CRLF
|
||||
var startLine = /^[A-Z_]+(\/\d\.\d)? /
|
||||
var requestLine = /^([A-Z_]+) (.+) [A-Z]+\/(\d)\.(\d)$/
|
||||
var statusLine = /^[A-Z]+\/(\d)\.(\d) (\d{3}) (.*)$/
|
||||
|
||||
module.exports = function (data, onlyHeaders) {
|
||||
return parse(normalize(data), onlyHeaders)
|
||||
}
|
||||
|
||||
function parse (str, onlyHeaders) {
|
||||
var line = firstLine(str)
|
||||
var match
|
||||
|
||||
if (onlyHeaders && startLine.test(line)) {
|
||||
return parseHeaders(str)
|
||||
} else if ((match = line.match(requestLine)) !== null) {
|
||||
return {
|
||||
method: match[1],
|
||||
url: match[2],
|
||||
version: { major: parseInt(match[3], 10), minor: parseInt(match[4], 10) },
|
||||
headers: parseHeaders(str)
|
||||
}
|
||||
} else if ((match = line.match(statusLine)) !== null) {
|
||||
return {
|
||||
version: { major: parseInt(match[1], 10), minor: parseInt(match[2], 10) },
|
||||
statusCode: parseInt(match[3], 10),
|
||||
statusMessage: match[4],
|
||||
headers: parseHeaders(str)
|
||||
}
|
||||
} else {
|
||||
return parseHeaders(str)
|
||||
}
|
||||
}
|
||||
|
||||
function parseHeaders (str) {
|
||||
var headers = {}
|
||||
var next = nextLine(str)
|
||||
var line = next()
|
||||
var index, name, value
|
||||
|
||||
if (startLine.test(line)) line = next()
|
||||
|
||||
while (line) {
|
||||
// subsequent lines in multi-line headers start with whitespace
|
||||
if (line[0] === ' ' || line[0] === '\t') {
|
||||
value += ' ' + line.trim()
|
||||
line = next()
|
||||
continue
|
||||
}
|
||||
|
||||
if (name) addHeaderLine(name, value, headers)
|
||||
|
||||
index = line.indexOf(':')
|
||||
name = line.substr(0, index)
|
||||
value = line.substr(index + 1).trim()
|
||||
|
||||
line = next()
|
||||
}
|
||||
|
||||
if (name) addHeaderLine(name, value, headers)
|
||||
|
||||
return headers
|
||||
}
|
||||
|
||||
function normalize (str) {
|
||||
if (str && str._header) str = str._header // extra headers from http.ServerResponse object
|
||||
if (!str || typeof str.toString !== 'function') return ''
|
||||
return str.toString().trim()
|
||||
}
|
||||
|
||||
function firstLine (str) {
|
||||
var nl = str.indexOf('\r\n')
|
||||
if (nl === -1) return str
|
||||
else return str.slice(0, nl)
|
||||
}
|
||||
|
||||
// The following function is lifted from:
|
||||
// https://github.com/nodejs/node/blob/f1294f5bfd7f02bce8029818be9c92de59749137/lib/_http_incoming.js#L116-L170
|
||||
//
|
||||
// Add the given (field, value) pair to the message
|
||||
//
|
||||
// Per RFC2616, section 4.2 it is acceptable to join multiple instances of the
|
||||
// same header with a ', ' if the header in question supports specification of
|
||||
// multiple values this way. If not, we declare the first instance the winner
|
||||
// and drop the second. Extended header fields (those beginning with 'x-') are
|
||||
// always joined.
|
||||
function addHeaderLine (field, value, dest) {
|
||||
field = field.toLowerCase()
|
||||
switch (field) {
|
||||
// Array headers:
|
||||
case 'set-cookie':
|
||||
if (dest[field] !== undefined) {
|
||||
dest[field].push(value)
|
||||
} else {
|
||||
dest[field] = [value]
|
||||
}
|
||||
break
|
||||
|
||||
// list is taken from:
|
||||
// https://mxr.mozilla.org/mozilla/source/netwerk/protocol/http/src/nsHttpHeaderArray.cpp
|
||||
case 'content-type':
|
||||
case 'content-length':
|
||||
case 'user-agent':
|
||||
case 'referer':
|
||||
case 'host':
|
||||
case 'authorization':
|
||||
case 'proxy-authorization':
|
||||
case 'if-modified-since':
|
||||
case 'if-unmodified-since':
|
||||
case 'from':
|
||||
case 'location':
|
||||
case 'max-forwards':
|
||||
case 'retry-after':
|
||||
case 'etag':
|
||||
case 'last-modified':
|
||||
case 'server':
|
||||
case 'age':
|
||||
case 'expires':
|
||||
// drop duplicates
|
||||
if (dest[field] === undefined) dest[field] = value
|
||||
break
|
||||
|
||||
default:
|
||||
// make comma-separated list
|
||||
if (typeof dest[field] === 'string') {
|
||||
dest[field] += ', ' + value
|
||||
} else {
|
||||
dest[field] = value
|
||||
}
|
||||
}
|
||||
}
|
70
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/package.json
generated
vendored
Normal file
70
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/package.json
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"http-headers@3.0.2",
|
||||
"/Users/sclay/projects/newsblur/node"
|
||||
]
|
||||
],
|
||||
"_from": "http-headers@3.0.2",
|
||||
"_id": "http-headers@3.0.2",
|
||||
"_inBundle": true,
|
||||
"_location": "/@postlight/mercury-parser/http-headers",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "http-headers@3.0.2",
|
||||
"name": "http-headers",
|
||||
"escapedName": "http-headers",
|
||||
"rawSpec": "3.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.0.2"
|
||||
},
|
||||
"_requiredBy": [],
|
||||
"_resolved": false,
|
||||
"_spec": "3.0.2",
|
||||
"_where": "/Users/sclay/projects/newsblur/node",
|
||||
"author": {
|
||||
"name": "Thomas Watson Steen",
|
||||
"email": "w@tson.dk",
|
||||
"url": "https://twitter.com/wa7son"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/watson/http-headers/issues"
|
||||
},
|
||||
"coordinates": [
|
||||
55.6757062,
|
||||
12.5774478
|
||||
],
|
||||
"dependencies": {
|
||||
"next-line": "^1.1.0"
|
||||
},
|
||||
"description": "Parse http headers",
|
||||
"devDependencies": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"standard": "^10.0.2",
|
||||
"tape": "^4.7.0"
|
||||
},
|
||||
"homepage": "https://github.com/watson/http-headers",
|
||||
"keywords": [
|
||||
"http",
|
||||
"https",
|
||||
"header",
|
||||
"headers",
|
||||
"parse",
|
||||
"parsing",
|
||||
"ServerResponse",
|
||||
"response"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "http-headers",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/watson/http-headers.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && tape test.js"
|
||||
},
|
||||
"version": "3.0.2"
|
||||
}
|
163
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/test.js
generated
vendored
Normal file
163
node/node_modules/@postlight/mercury-parser/node_modules/http-headers/test.js
generated
vendored
Normal file
|
@ -0,0 +1,163 @@
|
|||
'use strict'
|
||||
|
||||
var test = require('tape')
|
||||
var http = require('http')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var httpHeaders = require('./')
|
||||
|
||||
var requestLine = 'GET /foo HTTP/1.1\r\n'
|
||||
var statusLine = 'HTTP/1.1 200 OK\r\n'
|
||||
var msgHeaders = 'Date: Tue, 10 Jun 2014 07:29:20 GMT\r\n' +
|
||||
'Connection: keep-alive\r\n' +
|
||||
'Transfer-Encoding: chunked\r\n' +
|
||||
'Age: foo\r\n' +
|
||||
'Age: bar\r\n' +
|
||||
'Set-Cookie: cookie\r\n' +
|
||||
'X-List: A\r\n' +
|
||||
'X-Multi-Line-Header: Foo\r\n' +
|
||||
' Bar\r\n' +
|
||||
'X-List: B\r\n' +
|
||||
'\r\n'
|
||||
var requestMsg = requestLine + msgHeaders + 'Hello: World'
|
||||
var responseMsg = statusLine + msgHeaders + 'Hello: World'
|
||||
|
||||
var headerResult = {
|
||||
date: 'Tue, 10 Jun 2014 07:29:20 GMT',
|
||||
connection: 'keep-alive',
|
||||
'transfer-encoding': 'chunked',
|
||||
age: 'foo',
|
||||
'set-cookie': ['cookie'],
|
||||
'x-list': 'A, B',
|
||||
'x-multi-line-header': 'Foo Bar'
|
||||
}
|
||||
var responseResult = {
|
||||
version: { major: 1, minor: 1 },
|
||||
statusCode: 200,
|
||||
statusMessage: 'OK',
|
||||
headers: headerResult
|
||||
}
|
||||
var requestResult = {
|
||||
method: 'GET',
|
||||
url: '/foo',
|
||||
version: { major: 1, minor: 1 },
|
||||
headers: headerResult
|
||||
}
|
||||
|
||||
test('no argument', function (t) {
|
||||
t.deepEqual(httpHeaders(), {})
|
||||
t.deepEqual(httpHeaders(undefined, true), {})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('empty string', function (t) {
|
||||
t.deepEqual(httpHeaders(''), {})
|
||||
t.deepEqual(httpHeaders('', true), {})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('empty object', function (t) {
|
||||
t.deepEqual(httpHeaders({}), {})
|
||||
t.deepEqual(httpHeaders({}, true), {})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('empty buffer', function (t) {
|
||||
t.deepEqual(httpHeaders(new Buffer('')), {})
|
||||
t.deepEqual(httpHeaders(new Buffer(''), true), {})
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('start-line + header', function (t) {
|
||||
t.deepEqual(httpHeaders(requestLine + msgHeaders), requestResult)
|
||||
t.deepEqual(httpHeaders(statusLine + msgHeaders), responseResult)
|
||||
t.deepEqual(httpHeaders(new Buffer(requestLine + msgHeaders)), requestResult)
|
||||
t.deepEqual(httpHeaders(new Buffer(statusLine + msgHeaders)), responseResult)
|
||||
t.deepEqual(httpHeaders(requestLine + msgHeaders, true), headerResult)
|
||||
t.deepEqual(httpHeaders(statusLine + msgHeaders, true), headerResult)
|
||||
t.deepEqual(httpHeaders(new Buffer(requestLine + msgHeaders), true), headerResult)
|
||||
t.deepEqual(httpHeaders(new Buffer(statusLine + msgHeaders), true), headerResult)
|
||||
t.end()
|
||||
})
|
||||
|
||||
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) {
|
||||
t.deepEqual(httpHeaders(msgHeaders), headerResult)
|
||||
t.deepEqual(httpHeaders(new Buffer(msgHeaders)), headerResult)
|
||||
t.deepEqual(httpHeaders(msgHeaders, true), headerResult)
|
||||
t.deepEqual(httpHeaders(new Buffer(msgHeaders), true), headerResult)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('full http response', function (t) {
|
||||
t.deepEqual(httpHeaders(requestMsg), requestResult)
|
||||
t.deepEqual(httpHeaders(responseMsg), responseResult)
|
||||
t.deepEqual(httpHeaders(new Buffer(requestMsg)), requestResult)
|
||||
t.deepEqual(httpHeaders(new Buffer(responseMsg)), responseResult)
|
||||
t.deepEqual(httpHeaders(requestMsg, true), headerResult)
|
||||
t.deepEqual(httpHeaders(responseMsg, true), headerResult)
|
||||
t.deepEqual(httpHeaders(new Buffer(requestMsg), true), headerResult)
|
||||
t.deepEqual(httpHeaders(new Buffer(responseMsg), true), headerResult)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('http.ServerResponse', function (t) {
|
||||
t.test('real http.ServerResponse object', function (t) {
|
||||
var res = new http.ServerResponse({})
|
||||
t.deepEqual(httpHeaders(res), {})
|
||||
t.deepEqual(httpHeaders(res, true), {})
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('no _header property', function (t) {
|
||||
t.deepEqual(httpHeaders({ _header: undefined }), {})
|
||||
t.deepEqual(httpHeaders({ _header: undefined }, true), {})
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('empty string as _header', function (t) {
|
||||
t.deepEqual(httpHeaders({ _header: '' }), {})
|
||||
t.deepEqual(httpHeaders({ _header: '' }, true), {})
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('normal _header property', function (t) {
|
||||
t.deepEqual(httpHeaders({ _header: statusLine + msgHeaders }), responseResult)
|
||||
t.deepEqual(httpHeaders({ _header: statusLine + msgHeaders }, true), headerResult)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
test('set-cookie', function (t) {
|
||||
t.deepEqual(httpHeaders('Set-Cookie: foo'), { 'set-cookie': ['foo'] })
|
||||
t.deepEqual(httpHeaders('Set-Cookie: foo\r\nSet-Cookie: bar'), { 'set-cookie': ['foo', 'bar'] })
|
||||
t.end()
|
||||
})
|
1
node/node_modules/@postlight/mercury-parser/node_modules/next-line/.npmignore
generated
vendored
Normal file
1
node/node_modules/@postlight/mercury-parser/node_modules/next-line/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
node_modules
|
8
node/node_modules/@postlight/mercury-parser/node_modules/next-line/.travis.yml
generated
vendored
Normal file
8
node/node_modules/@postlight/mercury-parser/node_modules/next-line/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- '0.12'
|
||||
- '0.10'
|
||||
- '0.8'
|
||||
- 'iojs'
|
||||
before_install:
|
||||
- npm install -g npm@~1.4.6
|
21
node/node_modules/@postlight/mercury-parser/node_modules/next-line/LICENSE
generated
vendored
Normal file
21
node/node_modules/@postlight/mercury-parser/node_modules/next-line/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Thomas Watson Steen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
30
node/node_modules/@postlight/mercury-parser/node_modules/next-line/README.md
generated
vendored
Normal file
30
node/node_modules/@postlight/mercury-parser/node_modules/next-line/README.md
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
# next-line
|
||||
|
||||
Iterator over lines in a string:
|
||||
|
||||
- Support different newline types: CRLF, LF, CR
|
||||
- Support mixed newline formats in the same string
|
||||
|
||||
[](https://travis-ci.org/watson/next-line)
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm install next-line
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var next = require('next-line')('foo\r\nbar\nbaz')
|
||||
|
||||
console.log(next()) // => foo
|
||||
console.log(next()) // => bar
|
||||
console.log(next()) // => baz
|
||||
console.log(next()) // => null
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
38
node/node_modules/@postlight/mercury-parser/node_modules/next-line/index.js
generated
vendored
Normal file
38
node/node_modules/@postlight/mercury-parser/node_modules/next-line/index.js
generated
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
'use strict'
|
||||
|
||||
module.exports = function (str) {
|
||||
var offset = 0
|
||||
str = str.toString()
|
||||
|
||||
return iterator
|
||||
|
||||
function iterator () {
|
||||
var i1 = str.indexOf('\r\n', offset)
|
||||
var i2 = str.indexOf('\n', offset)
|
||||
var i3 = str.indexOf('\r', offset)
|
||||
|
||||
var indexes = [i1, i2, i3]
|
||||
var index = indexes
|
||||
.sort(function (a, b) {
|
||||
if (a > b) return 1
|
||||
if (a < b) return -1
|
||||
return 0
|
||||
})
|
||||
.filter(function (index) {
|
||||
return index !== -1
|
||||
})[0]
|
||||
|
||||
if (index !== undefined) return extract(index, index === i1 ? 2 : 1)
|
||||
|
||||
var length = str.length
|
||||
if (length === offset) return null
|
||||
|
||||
return extract(length, 0)
|
||||
}
|
||||
|
||||
function extract (index, skip) {
|
||||
var line = str.substr(offset, index - offset)
|
||||
offset = index + skip
|
||||
return line
|
||||
}
|
||||
}
|
69
node/node_modules/@postlight/mercury-parser/node_modules/next-line/package.json
generated
vendored
Normal file
69
node/node_modules/@postlight/mercury-parser/node_modules/next-line/package.json
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"next-line@1.1.0",
|
||||
"/Users/sclay/projects/newsblur/node"
|
||||
]
|
||||
],
|
||||
"_from": "next-line@1.1.0",
|
||||
"_id": "next-line@1.1.0",
|
||||
"_inBundle": true,
|
||||
"_location": "/@postlight/mercury-parser/next-line",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "next-line@1.1.0",
|
||||
"name": "next-line",
|
||||
"escapedName": "next-line",
|
||||
"rawSpec": "1.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@postlight/mercury-parser/http-headers"
|
||||
],
|
||||
"_resolved": false,
|
||||
"_spec": "1.1.0",
|
||||
"_where": "/Users/sclay/projects/newsblur/node",
|
||||
"author": {
|
||||
"name": "Thomas Watson Steen",
|
||||
"email": "w@tson.dk",
|
||||
"url": "https://twitter.com/wa7son"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/watson/next-line/issues"
|
||||
},
|
||||
"coordinates": [
|
||||
55.6877161,
|
||||
12.5955598
|
||||
],
|
||||
"description": "Iterator over lines in a string",
|
||||
"devDependencies": {
|
||||
"standard": "^5.1.1",
|
||||
"tape": "^4.2.0"
|
||||
},
|
||||
"homepage": "https://github.com/watson/next-line#readme",
|
||||
"keywords": [
|
||||
"line",
|
||||
"lines",
|
||||
"string",
|
||||
"str",
|
||||
"crlf",
|
||||
"iterate",
|
||||
"iterator",
|
||||
"loop",
|
||||
"next"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "next-line",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/watson/next-line.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && tape test.js"
|
||||
},
|
||||
"version": "1.1.0"
|
||||
}
|
40
node/node_modules/@postlight/mercury-parser/node_modules/next-line/test.js
generated
vendored
Normal file
40
node/node_modules/@postlight/mercury-parser/node_modules/next-line/test.js
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
'use strict'
|
||||
|
||||
var test = require('tape')
|
||||
var nextLine = require('./')
|
||||
|
||||
var strings = [
|
||||
'a\nb\nc\nd\n\ne',
|
||||
'a\rb\rc\rd\r\re',
|
||||
'a\r\nb\r\nc\r\nd\r\n\r\ne',
|
||||
'a\r\nb\nc\rd\r\n\ne',
|
||||
'a\r\nb\rc\nd\r\n\re'
|
||||
]
|
||||
|
||||
strings.forEach(function (str, index) {
|
||||
test('string ' + index, function (t) {
|
||||
var next = nextLine(str)
|
||||
t.equal(next(), 'a')
|
||||
t.equal(next(), 'b')
|
||||
t.equal(next(), 'c')
|
||||
t.equal(next(), 'd')
|
||||
t.equal(next(), '')
|
||||
t.equal(next(), 'e')
|
||||
t.equal(next(), null)
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
||||
strings.forEach(function (str, index) {
|
||||
test('buffer ' + index, function (t) {
|
||||
var next = nextLine(new Buffer(str))
|
||||
t.equal(next(), 'a')
|
||||
t.equal(next(), 'b')
|
||||
t.equal(next(), 'c')
|
||||
t.equal(next(), 'd')
|
||||
t.equal(next(), '')
|
||||
t.equal(next(), 'e')
|
||||
t.equal(next(), null)
|
||||
t.end()
|
||||
})
|
||||
})
|
Loading…
Add table
Reference in a new issue