2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#include "express/Response.h"
44#include "express/Request.h"
45#include "web/http/StatusCodes.h"
46#include "web/http/server/Response.h"
48#ifndef DOXYGEN_SHOULD_SKIP_THIS
51#include <nlohmann/json.hpp>
69 set("Content-Type", "application/json");
73 void Response::
download(
const std::string& file,
const std::function<
void(
int)>& onError) {
74 download(file
, std::filesystem::path(file).filename()
, onError
);
77 void Response::
download(
const std::string& file,
const std::string& fileName,
const std::function<
void(
int)>& onError) {
96 set("Content-Disposition", "attachment" + ((!fileName.empty()) ? (
"; filename=\"" + fileName +
"\"") :
"")
);
143 Response&
Response::
cookie(
const std::string& name,
const std::string& value,
const std::map<std::string, std::string>& options) {
177 void Response::
sendFile(
const std::string& file,
const std::function<
void(
int)>& callback) {
std::shared_ptr< web::http::server::Request > requestBase
void download(const std::string &file, const std::string &fileName, const std::function< void(int)> &onError)
std::shared_ptr< web::http::server::Response > responseBase
Response & attachment(const std::string &fileName="")
Response & cookie(const std::string &name, const std::string &value, const std::map< std::string, std::string > &options={})
Response & clearCookie(const std::string &name, const std::map< std::string, std::string > &options={})
void sendFile(const std::string &file, const std::function< void(int)> &callback)
void redirect(const std::string &loc)
void download(const std::string &file, const std::function< void(int)> &onError)
Response & set(const std::string &field, const std::string &value, bool overwrite=true)
Response & setTrailer(const std::string &field, const std::string &value, bool overwrite=true)
Response & sendFragment(const std::string &chunk)
Response & sendFragment(const char *chunk, std::size_t chunkLen)
Response & append(const std::string &field, const std::string &value)
void send(const std::string &chunk)
Response(const std::shared_ptr< web::http::server::Response > &response) noexcept
void redirect(int state, const std::string &loc)
Response & status(int status)
void send(const char *chunk, std::size_t chunkLen)
Response & vary(const std::string &field)
Response & type(const std::string &type)
Response & set(const std::map< std::string, std::string > &headers, bool overwrite=true)
web::http::server::SocketContext * getSocketContext() const
const std::string & header(const std::string &field)
void json(const nlohmann::json &json)
void sendStatus(int state)
void upgrade(const std::shared_ptr< Request > &request, const std::function< void(const std::string)> &status)
Response & location(const std::string &loc)
static std::string reason(int status)
SocketContext * getSocketContext() const
Response & status(int statusCode)
void send(const std::string &chunk)
void send(const char *chunk, std::size_t chunkLen)
Response & setTrailer(const std::string &field, const std::string &value, bool overwrite=true)
Response & set(const std::map< std::string, std::string > &headers, bool overwrite=true)
Response & set(const std::string &field, const std::string &value, bool overwrite=true)
void upgrade(const std::shared_ptr< Request > &request, const std::function< void(const std::string &)> &status)
Response & type(const std::string &type)
Response & sendFragment(const std::string &chunk)
Response & cookie(const std::string &name, const std::string &value, const std::map< std::string, std::string > &options={})
Response & append(const std::string &field, const std::string &value)
Response & sendFragment(const char *chunk, std::size_t chunkLen)
void sendFile(const std::string &file, const std::function< void(int)> &callback)
Response & clearCookie(const std::string &name, const std::map< std::string, std::string > &options={})
const std::string & header(const std::string &field)