blob: d4c701c09bdc301b06a0d01f696d40276eeea21c [file] [log] [blame]
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2016, Regents of the University of California.
4 *
5 * This file is part of ChronoShare, a decentralized file sharing application over NDN.
6 *
7 * ChronoShare is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * ChronoShare is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License along with
16 * ChronoShare, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ChronoShare authors and contributors.
19 */
Zhenkai Zhua9a7e1d2013-02-25 18:29:07 -080020//
21// reply.hpp
22// ~~~~~~~~~
23//
24// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
25//
26// Distributed under the Boost Software License, Version 1.0. (See accompanying
27// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
28//
29
30#ifndef HTTP_REPLY_HPP
31#define HTTP_REPLY_HPP
32
33#include <string>
34#include <vector>
35#include <boost/asio.hpp>
36#include "header.hpp"
37
38namespace http {
39namespace server {
40
41/// A reply to be sent to a client.
42struct reply
43{
44 /// The status of the reply.
45 enum status_type
46 {
47 ok = 200,
48 created = 201,
49 accepted = 202,
50 no_content = 204,
51 multiple_choices = 300,
52 moved_permanently = 301,
53 moved_temporarily = 302,
54 not_modified = 304,
55 bad_request = 400,
56 unauthorized = 401,
57 forbidden = 403,
58 not_found = 404,
59 internal_server_error = 500,
60 not_implemented = 501,
61 bad_gateway = 502,
62 service_unavailable = 503
63 } status;
64
65 /// The headers to be included in the reply.
66 std::vector<header> headers;
67
68 /// The content to be sent in the reply.
69 std::string content;
70
71 /// Convert the reply into a vector of buffers. The buffers do not own the
72 /// underlying memory blocks, therefore the reply object must remain valid and
73 /// not be changed until the write operation has completed.
74 std::vector<boost::asio::const_buffer> to_buffers();
75
76 /// Get a stock reply.
77 static reply stock_reply(status_type status);
78};
79
80} // namespace server
81} // namespace http
82
83#endif // HTTP_REPLY_HPP