Size: 1450 bytes.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// cs/net/http/status.hh
#ifndef CS_NET_HTTP_STATUS_HH
#define CS_NET_HTTP_STATUS_HH

#include <stdint.h>

#include <map>
#include <sstream>
#include <string>

namespace cs::net::http {

struct Status {
  Status() {}
  Status(uint32_t code, std::string name)
      : code(code), name(name) {}

  friend std::ostream& operator<<(std::ostream& os,
                                  const Status& status) {
    return os << status.code << " " << status.name;
  }

  std::string str() const {
    std::stringstream ss;
    ss << *this;
    return ss.str();
  };

  uint32_t code;
  std::string name;
};

static const Status HTTP_200_OK(200, "OK");
static const Status HTTP_201_CREATED(201, "CREATED");
static const Status Http301MovedPermanently(
    301, "MOVED PERMANENTLY");
static const Status HTTP_302_FOUND(302, "FOUND");
static const Status kHttp302Found(302, "FOUND");
static const Status HTTP_400_BAD_REQUEST(400,
                                         "BAD REQUEST");
static const Status HTTP_403_PERMISSION_DENIED(
    403, "PERMISSION DENIED");
static const Status HTTP_404_NOT_FOUND(404, "NOT FOUND");
static const Status HTTP_502_BAD_GATEWAY(502,
                                         "BAD GATEWAY");
static const Status HTTP_503_SERVICE_UNAVAILABLE(
    503, "SERVICE UNAVAILABLE");
static const Status HTTP_500_INTERNAL_SERVER_ERROR(
    500, "INTERNAL SERVER ERROR");

}  // namespace cs::net::http

#endif  // CS_NET_HTTP_STATUS_HH
v0 (commit) © 2025 @p13i.io | Load balancer proxied to: cs-code-viewer-3:8080 in 4ms.