SNode.C
Loading...
Searching...
No Matches
StatusCodes.h
Go to the documentation of this file.
1/*
2 * SNode.C - A Slim Toolkit for Network Communication
3 * Copyright (C) 2020, 2021 Volker Christian <me@vchrist.at>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/*
20 * MIT License
21 *
22 * Permission is hereby granted, free of charge, to any person obtaining a copy
23 * of this software and associated documentation files (the "Software"), to deal
24 * in the Software without restriction, including without limitation the rights
25 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26 * copies of the Software, and to permit persons to whom the Software is
27 * furnished to do so, subject to the following conditions:
28 *
29 * The above copyright notice and this permission notice shall be included in
30 * all copies or substantial portions of the Software.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
38 * THE SOFTWARE.
39 */
40
41#ifndef WEB_HTTP_STATUSCODES_H
42#define WEB_HTTP_STATUSCODES_H
43
44#ifndef DOXYGEN_SHOULD_SKIP_THIS
45
46#include <map>
47#include <string>
48
49#endif /* DOXYGEN_SHOULD_SKIP_THIS */
50
51namespace web::http {
52
53 class StatusCode {
54 public:
55 static std::string reason(int status);
56
57 static bool contains(int status);
58
59 private:
60 static std::map<int, std::string> statusCode;
61 };
62
63} // namespace web::http
64
65#endif // WEB_HTTP_STATUSCODES_H
std::shared_ptr< web::http::server::Request > requestBase
Definition Request.h:84
void download(const std::string &file, const std::string &fileName, const std::function< void(int)> &onError)
Definition Response.cpp:77
std::shared_ptr< web::http::server::Response > responseBase
Definition Response.h:96
Response & sendHeader()
Definition Response.cpp:181
Response & attachment(const std::string &fileName="")
Definition Response.cpp:95
Response & cookie(const std::string &name, const std::string &value, const std::map< std::string, std::string > &options={})
Definition Response.cpp:143
Response & clearCookie(const std::string &name, const std::map< std::string, std::string > &options={})
Definition Response.cpp:149
void sendFile(const std::string &file, const std::function< void(int)> &callback)
Definition Response.cpp:177
void redirect(const std::string &loc)
Definition Response.cpp:82
void download(const std::string &file, const std::function< void(int)> &onError)
Definition Response.cpp:73
Response & set(const std::string &field, const std::string &value, bool overwrite=true)
Definition Response.cpp:125
Response & setTrailer(const std::string &field, const std::string &value, bool overwrite=true)
Definition Response.cpp:155
Response & sendFragment(const std::string &chunk)
Definition Response.cpp:193
Response & sendFragment(const char *chunk, std::size_t chunkLen)
Definition Response.cpp:187
Response & append(const std::string &field, const std::string &value)
Definition Response.cpp:119
void send(const std::string &chunk)
Definition Response.cpp:165
Response(const std::shared_ptr< web::http::server::Response > &response) noexcept
Definition Response.cpp:57
void redirect(int state, const std::string &loc)
Definition Response.cpp:86
Response & status(int status)
Definition Response.cpp:113
void send(const char *chunk, std::size_t chunkLen)
Definition Response.cpp:161
Response & vary(const std::string &field)
Definition Response.cpp:107
Response & type(const std::string &type)
Definition Response.cpp:137
Response & set(const std::map< std::string, std::string > &headers, bool overwrite=true)
Definition Response.cpp:131
web::http::server::SocketContext * getSocketContext() const
Definition Response.cpp:64
const std::string & header(const std::string &field)
Definition Response.cpp:199
void json(const nlohmann::json &json)
Definition Response.cpp:68
void sendStatus(int state)
Definition Response.cpp:91
void upgrade(const std::shared_ptr< Request > &request, const std::function< void(const std::string)> &status)
Definition Response.cpp:169
Response & location(const std::string &loc)
Definition Response.cpp:101
static bool contains(int status)
static std::map< int, std::string > statusCode
Definition StatusCodes.h:60
static std::string reason(int status)
SocketContext * getSocketContext() const
Definition Response.cpp:457
Response & status(int statusCode)
Definition Response.cpp:102
void send(const std::string &chunk)
Definition Response.cpp:224
void send(const char *chunk, std::size_t chunkLen)
Definition Response.cpp:213
Response & setTrailer(const std::string &field, const std::string &value, bool overwrite=true)
Definition Response.cpp:194
Response & set(const std::map< std::string, std::string > &headers, bool overwrite=true)
Definition Response.cpp:120
Response & set(const std::string &field, const std::string &value, bool overwrite=true)
Definition Response.cpp:128
void upgrade(const std::shared_ptr< Request > &request, const std::function< void(const std::string &)> &status)
Definition Response.cpp:244
Response & type(const std::string &type)
Definition Response.cpp:174
Response & sendFragment(const std::string &chunk)
Definition Response.cpp:389
Response & cookie(const std::string &name, const std::string &value, const std::map< std::string, std::string > &options={})
Definition Response.cpp:178
Response & append(const std::string &field, const std::string &value)
Definition Response.cpp:108
Response & sendFragment(const char *chunk, std::size_t chunkLen)
Definition Response.cpp:371
void sendFile(const std::string &file, const std::function< void(int)> &callback)
Definition Response.cpp:292
Response & clearCookie(const std::string &name, const std::map< std::string, std::string > &options={})
Definition Response.cpp:184
const std::string & header(const std::string &field)
Definition Response.cpp:453