Skip to content

RFC: Pull out status_t to the top level to allow using those enum values from clients. #837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Pull out status_t to the top level to allow using those enum values f…
…rom clients.
  • Loading branch information
igorpeshansky committed May 1, 2018
commit 2aec5eaee9ad9f2eaa9f7f318126177e29d0d982
28 changes: 2 additions & 26 deletions boost/network/protocol/http/server/async_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <boost/asio/write.hpp>
#include <boost/network/protocol/http/algorithms/linearize.hpp>
#include <boost/network/protocol/http/server/request_parser.hpp>
#include <boost/network/protocol/http/status.hpp>
#include <boost/network/protocol/stream_handler.hpp>
#include <boost/network/utils/thread_pool.hpp>
#include <boost/optional.hpp>
Expand Down Expand Up @@ -71,32 +72,7 @@ extern void parse_headers(std::string const& input,
template <class Tag, class Handler>
struct async_connection
: std::enable_shared_from_this<async_connection<Tag, Handler> > {
/// The set of known status codes for HTTP server responses.
enum status_t {
ok = 200,
created = 201,
accepted = 202,
no_content = 204,
partial_content = 206,
multiple_choices = 300,
moved_permanently = 301,
moved_temporarily = 302,
not_modified = 304,
bad_request = 400,
unauthorized = 401,
forbidden = 403,
not_found = 404,
not_supported = 405,
not_acceptable = 406,
request_timeout = 408,
precondition_failed = 412,
unsatisfiable_range = 416,
internal_server_error = 500,
not_implemented = 501,
bad_gateway = 502,
service_unavailable = 503,
space_unavailable = 507
};
typedef boost::network::http::status_t status_t;

typedef typename string<Tag>::type string_type;
typedef basic_request<Tag> request;
Expand Down
39 changes: 39 additions & 0 deletions boost/network/protocol/http/status.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef BOOST_NETWORK_PROTOCOL_HTTP_STATUS_HPP_20180501
#define BOOST_NETWORK_PROTOCOL_HTTP_STATUS_HPP_20180501
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider naming this file status_code.hpp along with the suggested change to the enum name.


namespace boost {
namespace network {
namespace http {

/// The set of known status codes for HTTP server responses.
enum status_t {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're doing this, then I suggest dropping the _t suffix, and calling it status_code to be more descriptive.

Also, if we're going to do this as well, we might as well add the following:

  • An "unknown" value to be the default (say, 0).
  • More known status codes, even those that are extensions -- we can probably do those later on, instead of in this PR.

ok = 200,
created = 201,
accepted = 202,
no_content = 204,
partial_content = 206,
multiple_choices = 300,
moved_permanently = 301,
moved_temporarily = 302,
not_modified = 304,
bad_request = 400,
unauthorized = 401,
forbidden = 403,
not_found = 404,
not_supported = 405,
not_acceptable = 406,
request_timeout = 408,
precondition_failed = 412,
unsatisfiable_range = 416,
internal_server_error = 500,
not_implemented = 501,
bad_gateway = 502,
service_unavailable = 503,
space_unavailable = 507,
};

} // namespace http
} // namespace network
} // namespace boost

#endif // BOOST_NETWORK_PROTOCOL_HTTP_STATUS_HPP_20180501