first commit

This commit is contained in:
monjack
2025-06-20 18:01:48 +08:00
commit 6daa6d65c1
24611 changed files with 2512443 additions and 0 deletions

2
app_vue/node_modules/http-deceiver/.npmignore generated vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules/
npm-debug.log

5
app_vue/node_modules/http-deceiver/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.10"
- "0.12"
- "iojs"

31
app_vue/node_modules/http-deceiver/README.md generated vendored Normal file
View File

@ -0,0 +1,31 @@
# HTTP Deceiver
[![Build Status](https://secure.travis-ci.org/indutny/http-deceiver.png)](http://travis-ci.org/indutny/http-deceiver)
[![NPM version](https://badge.fury.io/js/http-deceiver.svg)](http://badge.fury.io/js/http-deceiver)
Deceive!
## LICENSE
This software is licensed under the MIT License.
Copyright Fedor Indutny, 2015.
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.

250
app_vue/node_modules/http-deceiver/lib/deceiver.js generated vendored Normal file
View File

@ -0,0 +1,250 @@
var assert = require('assert');
var util = require('util');
var Buffer = require('buffer').Buffer;
// Node.js version
var mode = /^v0\.8\./.test(process.version) ? 'rusty' :
/^v0\.(9|10)\./.test(process.version) ? 'old' :
/^v0\.12\./.test(process.version) ? 'normal' :
'modern';
var HTTPParser;
var methods;
var reverseMethods;
var kOnHeaders;
var kOnHeadersComplete;
var kOnMessageComplete;
var kOnBody;
if (mode === 'normal' || mode === 'modern') {
HTTPParser = process.binding('http_parser').HTTPParser;
methods = HTTPParser.methods;
// v6
if (!methods)
methods = process.binding('http_parser').methods;
reverseMethods = {};
methods.forEach(function(method, index) {
reverseMethods[method] = index;
});
kOnHeaders = HTTPParser.kOnHeaders | 0;
kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
kOnMessageComplete = HTTPParser.kOnMessageComplete | 0;
kOnBody = HTTPParser.kOnBody | 0;
} else {
kOnHeaders = 'onHeaders';
kOnHeadersComplete = 'onHeadersComplete';
kOnMessageComplete = 'onMessageComplete';
kOnBody = 'onBody';
}
function Deceiver(socket, options) {
this.socket = socket;
this.options = options || {};
this.isClient = this.options.isClient;
}
module.exports = Deceiver;
Deceiver.create = function create(stream, options) {
return new Deceiver(stream, options);
};
Deceiver.prototype._toHeaderList = function _toHeaderList(object) {
var out = [];
var keys = Object.keys(object);
for (var i = 0; i < keys.length; i++)
out.push(keys[i], object[keys[i]]);
return out;
};
Deceiver.prototype._isUpgrade = function _isUpgrade(request) {
return request.method === 'CONNECT' ||
request.headers.upgrade ||
request.headers.connection &&
/(^|\W)upgrade(\W|$)/i.test(request.headers.connection);
};
// TODO(indutny): support CONNECT
if (mode === 'modern') {
/*
function parserOnHeadersComplete(versionMajor, versionMinor, headers, method,
url, statusCode, statusMessage, upgrade,
shouldKeepAlive) {
*/
Deceiver.prototype.emitRequest = function emitRequest(request) {
var parser = this.socket.parser;
assert(parser, 'No parser present');
parser.execute = null;
var self = this;
var method = reverseMethods[request.method];
parser.execute = function execute() {
self._skipExecute(this);
this[kOnHeadersComplete](1,
1,
self._toHeaderList(request.headers),
method,
request.path,
0,
'',
self._isUpgrade(request),
true);
return 0;
};
this._emitEmpty();
};
Deceiver.prototype.emitResponse = function emitResponse(response) {
var parser = this.socket.parser;
assert(parser, 'No parser present');
parser.execute = null;
var self = this;
parser.execute = function execute() {
self._skipExecute(this);
this[kOnHeadersComplete](1,
1,
self._toHeaderList(response.headers),
response.path,
response.code,
response.status,
response.reason || '',
self._isUpgrade(response),
true);
return 0;
};
this._emitEmpty();
};
} else {
/*
`function parserOnHeadersComplete(info) {`
info = { .versionMajor, .versionMinor, .url, .headers, .method,
.statusCode, .statusMessage, .upgrade, .shouldKeepAlive }
*/
Deceiver.prototype.emitRequest = function emitRequest(request) {
var parser = this.socket.parser;
assert(parser, 'No parser present');
var method = request.method;
if (reverseMethods)
method = reverseMethods[method];
var info = {
versionMajor: 1,
versionMinor: 1,
url: request.path,
headers: this._toHeaderList(request.headers),
method: method,
statusCode: 0,
statusMessage: '',
upgrade: this._isUpgrade(request),
shouldKeepAlive: true
};
var self = this;
parser.execute = function execute() {
self._skipExecute(this);
this[kOnHeadersComplete](info);
return 0;
};
this._emitEmpty();
};
Deceiver.prototype.emitResponse = function emitResponse(response) {
var parser = this.socket.parser;
assert(parser, 'No parser present');
var info = {
versionMajor: 1,
versionMinor: 1,
url: response.path,
headers: this._toHeaderList(response.headers),
method: false,
statusCode: response.status,
statusMessage: response.reason || '',
upgrade: this._isUpgrade(response),
shouldKeepAlive: true
};
var self = this;
parser.execute = function execute() {
self._skipExecute(this);
this[kOnHeadersComplete](info);
return 0;
};
this._emitEmpty();
};
}
Deceiver.prototype._skipExecute = function _skipExecute(parser) {
var self = this;
var oldExecute = parser.constructor.prototype.execute;
var oldFinish = parser.constructor.prototype.finish;
parser.execute = null;
parser.finish = null;
parser.execute = function execute(buffer, start, len) {
// Parser reuse
if (this.socket !== self.socket) {
this.execute = oldExecute;
this.finish = oldFinish;
return this.execute(buffer, start, len);
}
if (start !== undefined)
buffer = buffer.slice(start, start + len);
self.emitBody(buffer);
return len;
};
parser.finish = function finish() {
// Parser reuse
if (this.socket !== self.socket) {
this.execute = oldExecute;
this.finish = oldFinish;
return this.finish();
}
this.execute = oldExecute;
this.finish = oldFinish;
self.emitMessageComplete();
};
};
Deceiver.prototype.emitBody = function emitBody(buffer) {
var parser = this.socket.parser;
assert(parser, 'No parser present');
parser[kOnBody](buffer, 0, buffer.length);
};
Deceiver.prototype._emitEmpty = function _emitEmpty() {
// Emit data to force out handling of UPGRADE
var empty = new Buffer(0);
if (this.socket.ondata)
this.socket.ondata(empty, 0, 0);
else
this.socket.emit('data', empty);
};
Deceiver.prototype.emitMessageComplete = function emitMessageComplete() {
var parser = this.socket.parser;
assert(parser, 'No parser present');
parser[kOnMessageComplete]();
};

30
app_vue/node_modules/http-deceiver/package.json generated vendored Normal file
View File

@ -0,0 +1,30 @@
{
"name": "http-deceiver",
"version": "1.2.7",
"description": "Deceive HTTP parser",
"main": "lib/deceiver.js",
"scripts": {
"test": "mocha --reporter=spec test/*-test.js"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/indutny/http-deceiver.git"
},
"keywords": [
"http",
"net",
"deceive"
],
"author": "Fedor Indutny <fedor@indutny.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/indutny/http-deceiver/issues"
},
"homepage": "https://github.com/indutny/http-deceiver#readme",
"devDependencies": {
"handle-thing": "^1.0.1",
"mocha": "^2.2.5",
"readable-stream": "^2.0.1",
"stream-pair": "^1.0.0"
}
}

226
app_vue/node_modules/http-deceiver/test/api-test.js generated vendored Normal file
View File

@ -0,0 +1,226 @@
var assert = require('assert');
var net = require('net');
var http = require('http');
var streamPair = require('stream-pair');
var thing = require('handle-thing');
var httpDeceiver = require('../');
describe('HTTP Deceiver', function() {
var handle;
var pair;
var socket;
var deceiver;
beforeEach(function() {
pair = streamPair.create();
handle = thing.create(pair.other);
socket = new net.Socket({ handle: handle });
// For v0.8
socket.readable = true;
socket.writable = true;
deceiver = httpDeceiver.create(socket);
});
it('should emit request', function(done) {
var server = http.createServer();
server.emit('connection', socket);
server.on('request', function(req, res) {
assert.equal(req.method, 'PUT');
assert.equal(req.url, '/hello');
assert.deepEqual(req.headers, { a: 'b' });
done();
});
deceiver.emitRequest({
method: 'PUT',
path: '/hello',
headers: {
a: 'b'
}
});
});
it('should emit response', function(done) {
var agent = new http.Agent();
agent.createConnection = function createConnection() {
return socket;
};
var client = http.request({
method: 'POST',
path: '/ok',
agent: agent
}, function(res) {
assert.equal(res.statusCode, 421);
assert.deepEqual(res.headers, { a: 'b' });
done();
});
process.nextTick(function() {
deceiver.emitResponse({
status: 421,
reason: 'F',
headers: {
a: 'b'
}
});
});
});
it('should override .execute and .finish', function(done) {
var server = http.createServer();
server.emit('connection', socket);
server.on('request', function(req, res) {
assert.equal(req.method, 'PUT');
assert.equal(req.url, '/hello');
assert.deepEqual(req.headers, { a: 'b' });
var actual = '';
req.on('data', function(chunk) {
actual += chunk;
});
req.once('end', function() {
assert.equal(actual, 'hello world');
done();
});
});
deceiver.emitRequest({
method: 'PUT',
path: '/hello',
headers: {
a: 'b'
}
});
pair.write('hello');
pair.end(' world');
});
it('should work with reusing parser', function(done) {
var server = http.createServer();
server.emit('connection', socket);
function secondRequest() {
pair = streamPair.create();
handle = thing.create(pair.other);
socket = new net.Socket({ handle: handle });
// For v0.8
socket.readable = true;
socket.writable = true;
server.emit('connection', socket);
pair.end('PUT /second HTTP/1.1\r\nContent-Length:11\r\n\r\nhello world');
}
server.on('request', function(req, res) {
var actual = '';
req.on('data', function(chunk) {
actual += chunk;
});
req.once('end', function() {
assert.equal(actual, 'hello world');
if (req.url === '/first')
secondRequest();
else
done();
});
});
deceiver.emitRequest({
method: 'PUT',
path: '/first',
headers: {
a: 'b'
}
});
pair.write('hello');
pair.end(' world');
});
it('should emit CONNECT request', function(done) {
var server = http.createServer();
server.emit('connection', socket);
server.on('connect', function(req, socket, bodyHead) {
assert.equal(req.method, 'CONNECT');
assert.equal(req.url, '/hello');
done();
});
deceiver.emitRequest({
method: 'CONNECT',
path: '/hello',
headers: {
}
});
});
it('should emit Upgrade request', function(done) {
var server = http.createServer();
server.emit('connection', socket);
server.on('upgrade', function(req, socket, bodyHead) {
assert.equal(req.method, 'POST');
assert.equal(req.url, '/hello');
socket.on('data', function(chunk) {
assert.equal(chunk + '', 'hm');
done();
});
});
deceiver.emitRequest({
method: 'POST',
path: '/hello',
headers: {
'upgrade': 'websocket'
}
});
pair.write('hm');
});
it('should emit Upgrade response', function(done) {
var agent = new http.Agent();
agent.createConnection = function createConnection() {
return socket;
};
var client = http.request({
method: 'POST',
path: '/ok',
headers: {
connection: 'upgrade',
upgrade: 'websocket'
},
agent: agent
}, function(res) {
assert(false);
});
client.on('upgrade', function(res, socket) {
assert.equal(res.statusCode, 421);
done();
});
process.nextTick(function() {
deceiver.emitResponse({
status: 421,
reason: 'F',
headers: {
upgrade: 'websocket'
}
});
});
});
});