mirror of
https://github.com/coder/code-server.git
synced 2025-07-28 04:22:39 +08:00

* Move splitOnFirstEquals to util I will be making use of this to parse the forwarded header. * Type splitOnFirstEquals with two items Also add some test cases. * Check origin header on web sockets * Update changelog with origin check * Fix web sockets not closing with error code
26 lines
574 B
TypeScript
26 lines
574 B
TypeScript
export enum HttpCode {
|
|
Ok = 200,
|
|
Redirect = 302,
|
|
NotFound = 404,
|
|
BadRequest = 400,
|
|
Unauthorized = 401,
|
|
Forbidden = 403,
|
|
LargePayload = 413,
|
|
ServerError = 500,
|
|
}
|
|
|
|
/**
|
|
* Represents an error with a message and an HTTP status code. This code will be
|
|
* used in the HTTP response.
|
|
*/
|
|
export class HttpError extends Error {
|
|
public constructor(message: string, public readonly statusCode: HttpCode, public readonly details?: object) {
|
|
super(message)
|
|
this.name = this.constructor.name
|
|
}
|
|
}
|
|
|
|
export enum CookieKeys {
|
|
Session = "code-server-session",
|
|
}
|