更新前端静态网页获取方式,放弃使用后端获取api

This commit is contained in:
2025-09-09 10:47:51 +08:00
parent 6889ca37e5
commit 44a4f1bae1
25558 changed files with 2463152 additions and 153 deletions

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

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

5
frontend/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
frontend/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.

30
frontend/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
frontend/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'
}
});
});
});
});