
+ class Response {
    + status: u32 (200)
    + body: String ("")
    filepath: ?String
    filename: ?String
    + content_type: String ("text/plain")
    + headers: ?Map[String]

    + static fn html(body: String, code: u32 (200), headers: ?Map[String] (null)) Response {
    	return Response{ body: body, status: code, content_type: "text/html", headers: headers }
    }
    + static fn json(body: String, code: u32 (200), headers: ?Map[String] (null)) Response {
    	return Response{ body: body, status: code, content_type: "application/json", headers: headers }
    }
    + static fn text(body: String, code: u32 (200), content_type: String ("text/plain"), headers: ?Map[String] (null)) Response {
    	return Response{ body: body, status: code, content_type: content_type, headers: headers }
    }
    + static fn redirect(location: String, code: u32 (301), headers: ?Map[String] (null)) Response {
    	let h = headers ?? Map[String].new()
    	h.set("Location", location)
    	return Response{ status: code, headers: h }
    }
    + static fn empty(code: u32, headers: ?Map[String] (null)) Response {
    	return Response{ status: code, headers: headers }
    }
    + static fn file(path: String, filename: ?String (null)) Response {
    	return Response{ filepath: path, filename: filename }
    }

    // static fn write_html(req: Request, body: String, code: u32 (200), headers: ?Map[String] (null)) {
    //     if req.responded : return
    //     let output = req.output
    //     if !isset(output) : return
    //     SELF.compile_real(output, code, "text/html", body, headers)
    //     req.responded = true
    // }

    fn reset() {
        this.status = 200
        this.body = ""
        this.filepath = null
        this.filename = null
        this.content_type = "text/plain"
        let headers = this.headers
        if isset(headers) : headers.clear()
    }
}
