cloudcms-server 0.9.270 → 0.9.271
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/middleware/proxy/proxy.js +5 -9
- package/package.json +2 -2
- package/temp/http-proxy/.auto-changelog +6 -0
- package/temp/http-proxy/.gitattributes +1 -0
- package/temp/http-proxy/CHANGELOG.md +1872 -0
- package/temp/http-proxy/CODE_OF_CONDUCT.md +74 -0
- package/temp/http-proxy/LICENSE +23 -0
- package/temp/http-proxy/README.md +568 -0
- package/temp/http-proxy/codecov.yml +10 -0
- package/temp/http-proxy/index.js +13 -0
- package/temp/http-proxy/lib/http-proxy/common.js +220 -0
- package/temp/http-proxy/lib/http-proxy/index.js +174 -0
- package/temp/http-proxy/lib/http-proxy/passes/web-incoming.js +174 -0
- package/temp/http-proxy/lib/http-proxy/passes/web-outgoing.js +135 -0
- package/temp/http-proxy/lib/http-proxy/passes/ws-incoming.js +141 -0
- package/temp/http-proxy/lib/index.js +13 -0
- package/temp/http-proxy/package.json +41 -0
- package/temp/http-proxy/renovate.json +19 -0
- package/temp/node-http-proxy/.eslintignore +3 -0
- package/temp/node-http-proxy/.eslintrc.js +21 -0
- package/temp/node-http-proxy/.github/workflows/ci.yml +30 -0
- package/temp/node-http-proxy/.prettierrc +7 -0
- package/temp/node-http-proxy/CODE_OF_CONDUCT.md +74 -0
- package/temp/node-http-proxy/LICENSE +23 -0
- package/temp/node-http-proxy/README.md +568 -0
- package/temp/node-http-proxy/codecov.yml +10 -0
- package/temp/node-http-proxy/dist/http-proxy/common.js +220 -0
- package/temp/node-http-proxy/dist/http-proxy/index.js +174 -0
- package/temp/node-http-proxy/dist/http-proxy/passes/web-incoming.js +174 -0
- package/temp/node-http-proxy/dist/http-proxy/passes/web-outgoing.js +135 -0
- package/temp/node-http-proxy/dist/http-proxy/passes/ws-incoming.js +141 -0
- package/temp/node-http-proxy/dist/index.js +13 -0
- package/temp/node-http-proxy/lib/http-proxy/common.js +265 -0
- package/temp/node-http-proxy/lib/http-proxy/index.ts +242 -0
- package/temp/node-http-proxy/lib/http-proxy/passes/web-incoming.js +208 -0
- package/temp/node-http-proxy/lib/http-proxy/passes/web-outgoing.js +163 -0
- package/temp/node-http-proxy/lib/http-proxy/passes/ws-incoming.js +179 -0
- package/temp/node-http-proxy/lib/index.ts +13 -0
- package/temp/node-http-proxy/lib/types.d.ts +277 -0
- package/temp/node-http-proxy/package-lock.json +5028 -0
- package/temp/node-http-proxy/package.json +47 -0
- package/temp/node-http-proxy/tsconfig.build.json +4 -0
- package/temp/node-http-proxy/tsconfig.json +115 -0
- package/temp/node-http-proxy/vitest.config.ts +9 -0
- package/util/proxy-factory.js +39 -128
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
const http = require('http'),
|
|
2
|
+
https = require('https'),
|
|
3
|
+
common = require('../common');
|
|
4
|
+
|
|
5
|
+
/*!
|
|
6
|
+
* Array of passes.
|
|
7
|
+
*
|
|
8
|
+
* A `pass` is just a function that is executed on `req, socket, options`
|
|
9
|
+
* so that you can easily add new checks while still keeping the base
|
|
10
|
+
* flexible.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Websockets Passes
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
module.exports = {
|
|
19
|
+
/**
|
|
20
|
+
* WebSocket requests must have the `GET` method and
|
|
21
|
+
* the `upgrade:websocket` header
|
|
22
|
+
*
|
|
23
|
+
* @param {ClientRequest} req Request object
|
|
24
|
+
* @param {Socket} socket
|
|
25
|
+
*
|
|
26
|
+
* @api private
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
checkMethodAndHeader: function checkMethodAndHeader(req, socket) {
|
|
30
|
+
if (req.method !== 'GET' || !req.headers.upgrade) {
|
|
31
|
+
socket.destroy();
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (req.headers.upgrade.toLowerCase() !== 'websocket') {
|
|
36
|
+
socket.destroy();
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Sets `x-forwarded-*` headers if specified in config.
|
|
43
|
+
*
|
|
44
|
+
* @param {ClientRequest} req Request object
|
|
45
|
+
* @param {Socket} socket
|
|
46
|
+
* @param {Object} options Config object passed to the proxy
|
|
47
|
+
*
|
|
48
|
+
* @api private
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
XHeaders: function XHeaders(req, socket, options) {
|
|
52
|
+
if (!options.xfwd) return;
|
|
53
|
+
|
|
54
|
+
const values = {
|
|
55
|
+
for: req.connection.remoteAddress || req.socket.remoteAddress,
|
|
56
|
+
port: common.getPort(req),
|
|
57
|
+
proto: common.hasEncryptedConnection(req) ? 'wss' : 'ws',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
['for', 'port', 'proto'].forEach(function (header) {
|
|
61
|
+
req.headers['x-forwarded-' + header] =
|
|
62
|
+
(req.headers['x-forwarded-' + header] || '') +
|
|
63
|
+
(req.headers['x-forwarded-' + header] ? ',' : '') +
|
|
64
|
+
values[header];
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Does the actual proxying. Make the request and upgrade it
|
|
70
|
+
* send the Switching Protocols request and pipe the sockets.
|
|
71
|
+
*
|
|
72
|
+
* @param {ClientRequest} req Request object
|
|
73
|
+
* @param {Socket} socket
|
|
74
|
+
* @param {Object} options Config object passed to the proxy
|
|
75
|
+
*
|
|
76
|
+
* @api private
|
|
77
|
+
*/
|
|
78
|
+
stream: function stream(req, socket, options, head, server, clb) {
|
|
79
|
+
const createHttpHeader = function (line, headers) {
|
|
80
|
+
return (
|
|
81
|
+
Object.keys(headers)
|
|
82
|
+
.reduce(
|
|
83
|
+
function (head, key) {
|
|
84
|
+
const value = headers[key];
|
|
85
|
+
|
|
86
|
+
if (!Array.isArray(value)) {
|
|
87
|
+
head.push(key + ': ' + value);
|
|
88
|
+
return head;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
for (let i = 0; i < value.length; i++) {
|
|
92
|
+
head.push(key + ': ' + value[i]);
|
|
93
|
+
}
|
|
94
|
+
return head;
|
|
95
|
+
},
|
|
96
|
+
[line],
|
|
97
|
+
)
|
|
98
|
+
.join('\r\n') + '\r\n\r\n'
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
common.setupSocket(socket);
|
|
103
|
+
|
|
104
|
+
if (head && head.length) socket.unshift(head);
|
|
105
|
+
|
|
106
|
+
const proxyReq = (
|
|
107
|
+
common.isSSL.test(options.target.protocol) ? https : http
|
|
108
|
+
).request(common.setupOutgoing(options.ssl || {}, options, req));
|
|
109
|
+
|
|
110
|
+
// Enable developers to modify the proxyReq before headers are sent
|
|
111
|
+
if (server) {
|
|
112
|
+
server.emit('proxyReqWs', proxyReq, req, socket, options, head);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Error Handler
|
|
116
|
+
proxyReq.on('error', onOutgoingError);
|
|
117
|
+
proxyReq.on('response', function (res) {
|
|
118
|
+
// if upgrade event isn't going to happen, close the socket
|
|
119
|
+
if (!res.upgrade) {
|
|
120
|
+
socket.write(
|
|
121
|
+
createHttpHeader(
|
|
122
|
+
'HTTP/' +
|
|
123
|
+
res.httpVersion +
|
|
124
|
+
' ' +
|
|
125
|
+
res.statusCode +
|
|
126
|
+
' ' +
|
|
127
|
+
res.statusMessage,
|
|
128
|
+
res.headers,
|
|
129
|
+
),
|
|
130
|
+
);
|
|
131
|
+
res.pipe(socket);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
proxyReq.on('upgrade', function (proxyRes, proxySocket, proxyHead) {
|
|
136
|
+
proxySocket.on('error', onOutgoingError);
|
|
137
|
+
|
|
138
|
+
// Allow us to listen when the websocket has completed
|
|
139
|
+
proxySocket.on('end', function () {
|
|
140
|
+
server.emit('close', proxyRes, proxySocket, proxyHead);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// The pipe below will end proxySocket if socket closes cleanly, but not
|
|
144
|
+
// if it errors (eg, vanishes from the net and starts returning
|
|
145
|
+
// EHOSTUNREACH). We need to do that explicitly.
|
|
146
|
+
socket.on('error', function () {
|
|
147
|
+
proxySocket.end();
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
common.setupSocket(proxySocket);
|
|
151
|
+
|
|
152
|
+
if (proxyHead && proxyHead.length) proxySocket.unshift(proxyHead);
|
|
153
|
+
|
|
154
|
+
//
|
|
155
|
+
// Remark: Handle writing the headers to the socket when switching protocols
|
|
156
|
+
// Also handles when a header is an array
|
|
157
|
+
//
|
|
158
|
+
socket.write(
|
|
159
|
+
createHttpHeader('HTTP/1.1 101 Switching Protocols', proxyRes.headers),
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
proxySocket.pipe(socket).pipe(proxySocket);
|
|
163
|
+
|
|
164
|
+
server.emit('open', proxySocket);
|
|
165
|
+
server.emit('proxySocket', proxySocket); //DEPRECATED.
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return proxyReq.end(); // XXX: CHECK IF THIS IS THIS CORRECT
|
|
169
|
+
|
|
170
|
+
function onOutgoingError(err) {
|
|
171
|
+
if (clb) {
|
|
172
|
+
clb(err, req, socket);
|
|
173
|
+
} else {
|
|
174
|
+
server.emit('error', err, req, socket);
|
|
175
|
+
}
|
|
176
|
+
socket.end();
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Caron dimonio, con occhi di bragia
|
|
3
|
+
* loro accennando, tutte le raccoglie;
|
|
4
|
+
* batte col remo qualunque s’adagia
|
|
5
|
+
*
|
|
6
|
+
* Charon the demon, with the eyes of glede,
|
|
7
|
+
* Beckoning to them, collects them all together,
|
|
8
|
+
* Beats with his oar whoever lags behind
|
|
9
|
+
*
|
|
10
|
+
* Dante - The Divine Comedy (Canto III)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export = './http-proxy';
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// Type definitions for node-http-proxy 1.17
|
|
2
|
+
// Project: https://github.com/nodejitsu/node-http-proxy
|
|
3
|
+
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>
|
|
4
|
+
// Florian Oellerich <https://github.com/Raigen>
|
|
5
|
+
// Daniel Schmidt <https://github.com/DanielMSchmidt>
|
|
6
|
+
// Jordan Abreu <https://github.com/jabreu610>
|
|
7
|
+
// Samuel Bodin <https://github.com/bodinsamuel>
|
|
8
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
9
|
+
// TypeScript Version: 2.1
|
|
10
|
+
|
|
11
|
+
/// <reference types="node" />
|
|
12
|
+
|
|
13
|
+
import * as net from 'net';
|
|
14
|
+
import * as http from 'http';
|
|
15
|
+
import * as events from 'events';
|
|
16
|
+
import * as url from 'url';
|
|
17
|
+
import * as stream from 'stream';
|
|
18
|
+
|
|
19
|
+
interface ProxyTargetDetailed {
|
|
20
|
+
host: string;
|
|
21
|
+
port: number;
|
|
22
|
+
protocol?: string | undefined;
|
|
23
|
+
hostname?: string | undefined;
|
|
24
|
+
socketPath?: string | undefined;
|
|
25
|
+
key?: string | undefined;
|
|
26
|
+
passphrase?: string | undefined;
|
|
27
|
+
pfx?: Buffer | string | undefined;
|
|
28
|
+
cert?: string | undefined;
|
|
29
|
+
ca?: string | undefined;
|
|
30
|
+
ciphers?: string | undefined;
|
|
31
|
+
secureProtocol?: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare class Server extends events.EventEmitter {
|
|
35
|
+
/**
|
|
36
|
+
* Creates the proxy server with specified options.
|
|
37
|
+
* @param options - Config object passed to the proxy
|
|
38
|
+
*/
|
|
39
|
+
constructor(options?: Server.ServerOptions);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Used for proxying regular HTTP(S) requests
|
|
43
|
+
* @param req - Client request.
|
|
44
|
+
* @param res - Client response.
|
|
45
|
+
* @param options - Additional options.
|
|
46
|
+
*/
|
|
47
|
+
web(
|
|
48
|
+
req: http.IncomingMessage,
|
|
49
|
+
res: http.ServerResponse,
|
|
50
|
+
options?: Server.ServerOptions,
|
|
51
|
+
callback?: Server.ErrorCallback,
|
|
52
|
+
): void;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Used for proxying regular HTTP(S) requests
|
|
56
|
+
* @param req - Client request.
|
|
57
|
+
* @param socket - Client socket.
|
|
58
|
+
* @param head - Client head.
|
|
59
|
+
* @param options - Additionnal options.
|
|
60
|
+
*/
|
|
61
|
+
ws(
|
|
62
|
+
req: http.IncomingMessage,
|
|
63
|
+
socket: any,
|
|
64
|
+
head: any,
|
|
65
|
+
options?: Server.ServerOptions,
|
|
66
|
+
callback?: Server.ErrorCallback,
|
|
67
|
+
): void;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A function that wraps the object in a webserver, for your convenience
|
|
71
|
+
* @param port - Port to listen on
|
|
72
|
+
*/
|
|
73
|
+
listen(port: number): Server;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A function that closes the inner webserver and stops listening on given port
|
|
77
|
+
*/
|
|
78
|
+
close(callback?: () => void): void;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Creates the proxy server with specified options.
|
|
82
|
+
* @param options Config object passed to the proxy
|
|
83
|
+
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
84
|
+
*/
|
|
85
|
+
static createProxyServer(options?: Server.ServerOptions): Server;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Creates the proxy server with specified options.
|
|
89
|
+
* @param options Config object passed to the proxy
|
|
90
|
+
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
91
|
+
*/
|
|
92
|
+
static createServer(options?: Server.ServerOptions): Server;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Creates the proxy server with specified options.
|
|
96
|
+
* @param options Config object passed to the proxy
|
|
97
|
+
* @returns Proxy object with handlers for `ws` and `web` requests
|
|
98
|
+
*/
|
|
99
|
+
static createProxy(options?: Server.ServerOptions): Server;
|
|
100
|
+
|
|
101
|
+
addListener(event: string, listener: () => void): this;
|
|
102
|
+
|
|
103
|
+
on(event: string, listener: () => void): this;
|
|
104
|
+
on(event: 'error', listener: Server.ErrorCallback): this;
|
|
105
|
+
on(event: 'start', listener: Server.StartCallback): this;
|
|
106
|
+
on(event: 'proxyReq', listener: Server.ProxyReqCallback): this;
|
|
107
|
+
on(event: 'proxyRes', listener: Server.ProxyResCallback): this;
|
|
108
|
+
on(event: 'proxyReqWs', listener: Server.ProxyReqWsCallback): this;
|
|
109
|
+
on(event: 'econnreset', listener: Server.EconnresetCallback): this;
|
|
110
|
+
on(event: 'end', listener: Server.EndCallback): this;
|
|
111
|
+
on(event: 'open', listener: Server.OpenCallback): this;
|
|
112
|
+
on(event: 'close', listener: Server.CloseCallback): this;
|
|
113
|
+
|
|
114
|
+
once(event: string, listener: () => void): this;
|
|
115
|
+
once(event: 'error', listener: Server.ErrorCallback): this;
|
|
116
|
+
once(event: 'start', listener: Server.StartCallback): this;
|
|
117
|
+
once(event: 'proxyReq', listener: Server.ProxyReqCallback): this;
|
|
118
|
+
once(event: 'proxyRes', listener: Server.ProxyResCallback): this;
|
|
119
|
+
once(event: 'proxyReqWs', listener: Server.ProxyReqWsCallback): this;
|
|
120
|
+
once(event: 'econnreset', listener: Server.EconnresetCallback): this;
|
|
121
|
+
once(event: 'end', listener: Server.EndCallback): this;
|
|
122
|
+
once(event: 'open', listener: Server.OpenCallback): this;
|
|
123
|
+
once(event: 'close', listener: Server.CloseCallback): this;
|
|
124
|
+
|
|
125
|
+
removeListener(event: string, listener: () => void): this;
|
|
126
|
+
|
|
127
|
+
removeAllListeners(event?: string): this;
|
|
128
|
+
|
|
129
|
+
getMaxListeners(): number;
|
|
130
|
+
|
|
131
|
+
setMaxListeners(n: number): this;
|
|
132
|
+
|
|
133
|
+
listeners(event: string): Array<() => void>;
|
|
134
|
+
|
|
135
|
+
emit(event: string, ...args: any[]): boolean;
|
|
136
|
+
|
|
137
|
+
listenerCount(type: string): number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
declare namespace Server {
|
|
141
|
+
type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
|
|
142
|
+
type ProxyTargetUrl = string | Partial<url.Url>;
|
|
143
|
+
|
|
144
|
+
interface ServerOptions {
|
|
145
|
+
/** URL string to be parsed with the url module. */
|
|
146
|
+
target?: ProxyTarget | undefined;
|
|
147
|
+
/** URL string to be parsed with the url module. */
|
|
148
|
+
forward?: ProxyTargetUrl | undefined;
|
|
149
|
+
/** Object to be passed to http(s).request. */
|
|
150
|
+
agent?: any;
|
|
151
|
+
/** Object to be passed to https.createServer(). */
|
|
152
|
+
ssl?: any;
|
|
153
|
+
/** If you want to proxy websockets. */
|
|
154
|
+
ws?: boolean | undefined;
|
|
155
|
+
/** Adds x- forward headers. */
|
|
156
|
+
xfwd?: boolean | undefined;
|
|
157
|
+
/** Verify SSL certificate. */
|
|
158
|
+
secure?: boolean | undefined;
|
|
159
|
+
/** Explicitly specify if we are proxying to another proxy. */
|
|
160
|
+
toProxy?: boolean | undefined;
|
|
161
|
+
/** Specify whether you want to prepend the target's path to the proxy path. */
|
|
162
|
+
prependPath?: boolean | undefined;
|
|
163
|
+
/** Specify whether you want to ignore the proxy path of the incoming request. */
|
|
164
|
+
ignorePath?: boolean | undefined;
|
|
165
|
+
/** Local interface string to bind for outgoing connections. */
|
|
166
|
+
localAddress?: string | undefined;
|
|
167
|
+
/** Changes the origin of the host header to the target URL. */
|
|
168
|
+
changeOrigin?: boolean | undefined;
|
|
169
|
+
/** specify whether you want to keep letter case of response header key */
|
|
170
|
+
preserveHeaderKeyCase?: boolean | undefined;
|
|
171
|
+
/** Basic authentication i.e. 'user:password' to compute an Authorization header. */
|
|
172
|
+
auth?: string | undefined;
|
|
173
|
+
/** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
|
|
174
|
+
hostRewrite?: string | undefined;
|
|
175
|
+
/** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
|
|
176
|
+
autoRewrite?: boolean | undefined;
|
|
177
|
+
/** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
|
|
178
|
+
protocolRewrite?: string | undefined;
|
|
179
|
+
/** rewrites domain of set-cookie headers. */
|
|
180
|
+
cookieDomainRewrite?:
|
|
181
|
+
| false
|
|
182
|
+
| string
|
|
183
|
+
| { [oldDomain: string]: string }
|
|
184
|
+
| undefined;
|
|
185
|
+
/** rewrites path of set-cookie headers. Default: false */
|
|
186
|
+
cookiePathRewrite?:
|
|
187
|
+
| false
|
|
188
|
+
| string
|
|
189
|
+
| { [oldPath: string]: string }
|
|
190
|
+
| undefined;
|
|
191
|
+
/** object with extra headers to be added to target requests. */
|
|
192
|
+
headers?: { [header: string]: string } | undefined;
|
|
193
|
+
/** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
|
|
194
|
+
proxyTimeout?: number | undefined;
|
|
195
|
+
/** Timeout (in milliseconds) for incoming requests */
|
|
196
|
+
timeout?: number | undefined;
|
|
197
|
+
/** Specify whether you want to follow redirects. Default: false */
|
|
198
|
+
followRedirects?: boolean | undefined;
|
|
199
|
+
/** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
|
|
200
|
+
selfHandleResponse?: boolean | undefined;
|
|
201
|
+
/** Buffer */
|
|
202
|
+
buffer?: stream.Stream | undefined;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
type StartCallback<
|
|
206
|
+
TIncomingMessage = http.IncomingMessage,
|
|
207
|
+
TServerResponse = http.ServerResponse,
|
|
208
|
+
> = (
|
|
209
|
+
req: TIncomingMessage,
|
|
210
|
+
res: TServerResponse,
|
|
211
|
+
target: ProxyTargetUrl,
|
|
212
|
+
) => void;
|
|
213
|
+
type ProxyReqCallback<
|
|
214
|
+
TClientRequest = http.ClientRequest,
|
|
215
|
+
TIncomingMessage = http.IncomingMessage,
|
|
216
|
+
TServerResponse = http.ServerResponse,
|
|
217
|
+
> = (
|
|
218
|
+
proxyReq: TClientRequest,
|
|
219
|
+
req: TIncomingMessage,
|
|
220
|
+
res: TServerResponse,
|
|
221
|
+
options: ServerOptions,
|
|
222
|
+
) => void;
|
|
223
|
+
type ProxyResCallback<
|
|
224
|
+
TIncomingMessage = http.IncomingMessage,
|
|
225
|
+
TServerResponse = http.ServerResponse,
|
|
226
|
+
> = (
|
|
227
|
+
proxyRes: TIncomingMessage,
|
|
228
|
+
req: TIncomingMessage,
|
|
229
|
+
res: TServerResponse,
|
|
230
|
+
) => void;
|
|
231
|
+
type ProxyReqWsCallback<
|
|
232
|
+
TClientRequest = http.ClientRequest,
|
|
233
|
+
TIncomingMessage = http.IncomingMessage,
|
|
234
|
+
> = (
|
|
235
|
+
proxyReq: TClientRequest,
|
|
236
|
+
req: TIncomingMessage,
|
|
237
|
+
socket: net.Socket,
|
|
238
|
+
options: ServerOptions,
|
|
239
|
+
head: any,
|
|
240
|
+
) => void;
|
|
241
|
+
type EconnresetCallback<
|
|
242
|
+
TError = Error,
|
|
243
|
+
TIncomingMessage = http.IncomingMessage,
|
|
244
|
+
TServerResponse = http.ServerResponse,
|
|
245
|
+
> = (
|
|
246
|
+
err: TError,
|
|
247
|
+
req: TIncomingMessage,
|
|
248
|
+
res: TServerResponse,
|
|
249
|
+
target: ProxyTargetUrl,
|
|
250
|
+
) => void;
|
|
251
|
+
type EndCallback<
|
|
252
|
+
TIncomingMessage = http.IncomingMessage,
|
|
253
|
+
TServerResponse = http.ServerResponse,
|
|
254
|
+
> = (
|
|
255
|
+
req: TIncomingMessage,
|
|
256
|
+
res: TServerResponse,
|
|
257
|
+
proxyRes: TIncomingMessage,
|
|
258
|
+
) => void;
|
|
259
|
+
type OpenCallback = (proxySocket: net.Socket) => void;
|
|
260
|
+
type CloseCallback<TIncomingMessage = http.IncomingMessage> = (
|
|
261
|
+
proxyRes: TIncomingMessage,
|
|
262
|
+
proxySocket: net.Socket,
|
|
263
|
+
proxyHead: any,
|
|
264
|
+
) => void;
|
|
265
|
+
type ErrorCallback<
|
|
266
|
+
TError = Error,
|
|
267
|
+
TIncomingMessage = http.IncomingMessage,
|
|
268
|
+
TServerResponse = http.ServerResponse,
|
|
269
|
+
> = (
|
|
270
|
+
err: TError,
|
|
271
|
+
req: TIncomingMessage,
|
|
272
|
+
res: TServerResponse | net.Socket,
|
|
273
|
+
target?: ProxyTargetUrl,
|
|
274
|
+
) => void;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export = Server;
|