<commit_before>/**
 * This class provide a way to customize the http response.
 *
 * @export
 * @class HttpResponse
 */
export class HttpResponse {
    static readonly VulcainContentType = "application/vulcain";

    /**
     * Http code (default is 200)
     *
     * @type {number}
     * @memberOf HttpResponse
     */
    public statusCode: number;
    /**
     * List of response headers
     *
     * @type {Map<string, string>}
     * @memberOf HttpResponse
     */
    public headers: Map<string, string>;
    /**
     * Define a specific ContentType
     *
     * @type {string}
     * @memberOf HttpResponse
     */
    public contentType: string;
    /**
     * Response content
     *
     * @type {*}
     * @memberOf HttpResponse
     */
    public content: any;

    /**
     * Content encoding (like binary, hex,...)
     *
     * @type {string}
     * @memberOf HttpResponse
     */
    public encoding: string;

    constructor(content?, statusCode=200) {
        this.headers = new Map<string, string>();
        this.statusCode = statusCode;
        this.content = content;
    }

        /**
     * Add a custom header value to the response
     *
     * @param {string} name
     * @param {string} value
     */
    addHeader(name: string, value: string) {
        this.headers.set(name, value);
    }
}

export class HttpRedirectResponse extends HttpResponse {
    constructor(url: string) {
        super();
        if (!url)
            throw new Error("Url is required");
        this.statusCode = 302;
        this.addHeader("Location", url);
    }
}

export class BadRequestResponse extends HttpResponse {
    constructor(content) {
        super(content);
        if (typeof content === "string") {
            this.content = {
                error: { message: content }
            };
        }
    }
}

export class VulcainResponse extends HttpResponse {
    constructor(content) {
        super(content);
        this.contentType = HttpResponse.VulcainContentType;
    }
}<commit_msg>badrequesterror send 400 status code<commit_after>/**
 * This class provide a way to customize the http response.
 *
 * @export
 * @class HttpResponse
 */
export class HttpResponse {
    static readonly VulcainContentType = "application/vulcain";

    /**
     * Http code (default is 200)
     *
     * @type {number}
     * @memberOf HttpResponse
     */
    public statusCode: number;
    /**
     * List of response headers
     *
     * @type {Map<string, string>}
     * @memberOf HttpResponse
     */
    public headers: Map<string, string>;
    /**
     * Define a specific ContentType
     *
     * @type {string}
     * @memberOf HttpResponse
     */
    public contentType: string;
    /**
     * Response content
     *
     * @type {*}
     * @memberOf HttpResponse
     */
    public content: any;

    /**
     * Content encoding (like binary, hex,...)
     *
     * @type {string}
     * @memberOf HttpResponse
     */
    public encoding: string;

    constructor(content?, statusCode=200) {
        this.headers = new Map<string, string>();
        this.statusCode = statusCode;
        this.content = content;
    }

        /**
     * Add a custom header value to the response
     *
     * @param {string} name
     * @param {string} value
     */
    addHeader(name: string, value: string) {
        this.headers.set(name, value);
    }
}

export class HttpRedirectResponse extends HttpResponse {
    constructor(url: string) {
        super();
        if (!url)
            throw new Error("Url is required");
        this.statusCode = 302;
        this.addHeader("Location", url);
    }
}

export class BadRequestResponse extends HttpResponse {
    constructor(content) {
        super(content, 400);
        if (typeof content === "string") {
            this.content = {
                error: { message: content }
            };
        }
    }
}

export class VulcainResponse extends HttpResponse {
    constructor(content) {
        super(content);
        this.contentType = HttpResponse.VulcainContentType;
    }
}
{'fraction_non_alphanumeric': 0.11349089118660759, 'fraction_numerical': 0.005908419497784343, 'mean_word_length': 2.054887218045113, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1172505', 'n_tokens_mistral': 1170, 'n_tokens_neox': 1130, 'n_words': 305}