diagnostics-channel.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { Socket } from "net";
  2. import { URL } from "url";
  3. import Connector from "./connector";
  4. import Dispatcher from "./dispatcher";
  5. declare namespace DiagnosticsChannel {
  6. interface Request {
  7. origin?: string | URL;
  8. completed: boolean;
  9. method?: Dispatcher.HttpMethod;
  10. path: string;
  11. headers: string;
  12. addHeader(key: string, value: string): Request;
  13. }
  14. interface Response {
  15. statusCode: number;
  16. statusText: string;
  17. headers: Array<Buffer>;
  18. }
  19. type Error = unknown;
  20. interface ConnectParams {
  21. host: URL["host"];
  22. hostname: URL["hostname"];
  23. protocol: URL["protocol"];
  24. port: URL["port"];
  25. servername: string | null;
  26. }
  27. type Connector = Connector.connector;
  28. export interface RequestCreateMessage {
  29. request: Request;
  30. }
  31. export interface RequestBodySentMessage {
  32. request: Request;
  33. }
  34. export interface RequestHeadersMessage {
  35. request: Request;
  36. response: Response;
  37. }
  38. export interface RequestTrailersMessage {
  39. request: Request;
  40. trailers: Array<Buffer>;
  41. }
  42. export interface RequestErrorMessage {
  43. request: Request;
  44. error: Error;
  45. }
  46. export interface ClientSendHeadersMessage {
  47. request: Request;
  48. headers: string;
  49. socket: Socket;
  50. }
  51. export interface ClientBeforeConnectMessage {
  52. connectParams: ConnectParams;
  53. connector: Connector;
  54. }
  55. export interface ClientConnectedMessage {
  56. socket: Socket;
  57. connectParams: ConnectParams;
  58. connector: Connector;
  59. }
  60. export interface ClientConnectErrorMessage {
  61. error: Error;
  62. socket: Socket;
  63. connectParams: ConnectParams;
  64. connector: Connector;
  65. }
  66. }