f2e-server3
Version:
f2e-server 3.0
84 lines (83 loc) • 2.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.NativeResponse = void 0;
class NativeResponse {
request;
response;
constructor(request, response) {
this.request = request;
this.response = response;
}
pause() {
throw new Error('Method not implemented.');
}
resume() {
throw new Error('Method not implemented.');
}
writeStatus(status) {
const [statusCode, ...statusText] = status.toString().split(/\s+/);
this.response.statusCode = Number(statusCode);
this.response.statusMessage = statusText.join(' ');
return this;
}
writeHeader(key, value) {
this.response.setHeader(key.toString(), value.toString());
return this;
}
write(chunk) {
return this.response.write(chunk);
}
end(body, closeConnection) {
this.response.end(body);
return this;
}
endWithoutBody(reportedContentLength, closeConnection) {
return this.end(undefined, closeConnection);
}
tryEnd(fullBodyOrChunk, totalSize) {
throw new Error('Method not implemented.');
}
close() {
this.response.destroy();
return this;
}
getWriteOffset() {
throw new Error('Method not implemented.');
}
onWritable(handler) {
throw new Error('Method not implemented.');
}
onAborted(handler) {
this.request.socket.addListener('close', handler);
return this;
}
onData(handler) {
throw new Error('Method not implemented.');
}
getRemoteAddress() {
throw new Error('Method not implemented.');
}
getRemoteAddressAsText() {
const buffer = Buffer.from((this.request.socket.remoteAddress || '').split(',')[0], 'utf-8');
return buffer.buffer.slice(buffer.byteOffset, buffer.byteLength);
}
getProxiedRemoteAddress() {
throw new Error('Method not implemented.');
}
getProxiedRemoteAddressAsText() {
const ip = this.request.headers['x-forwarded-for'];
const buffer = Buffer.from((ip ? ip.toString() : '').split(',')[0], 'utf-8');
return buffer.buffer.slice(buffer.byteOffset, buffer.byteLength);
}
cork(cb) {
const resp = this.response;
if (resp.writable && !resp.writableEnded) {
cb && cb();
}
return this;
}
upgrade(userData, secWebSocketKey, secWebSocketProtocol, secWebSocketExtensions, context) {
throw new Error('Method not implemented.');
}
}
exports.NativeResponse = NativeResponse;