Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 2x 2x 2x | import {getBody} from './util';
import {listToUint8} from '@jsonjoy.com/buffers/lib/concat';
import type * as http from 'http';
import type {JsonValueCodec} from '@jsonjoy.com/json-pack/lib/codecs/types';
import type {RpcMessageCodec, ConnectionContext} from '../types';
export class Http1ConnectionContext<Meta = Record<string, unknown>> implements ConnectionContext<Meta> {
constructor(
public readonly req: http.IncomingMessage,
public readonly res: http.ServerResponse,
public path: string,
public query: string,
public readonly ip: string,
public token: string,
public readonly params: string[] | null,
public readonly meta: Meta,
public reqCodec: JsonValueCodec,
public resCodec: JsonValueCodec,
public msgCodec: RpcMessageCodec,
) {}
public async body(maxPayload: number): Promise<Uint8Array> {
const list = await getBody(this.req, maxPayload);
const bodyUint8 = listToUint8(list);
return bodyUint8;
}
}
|