join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
http_protocol.hpp
Go to the documentation of this file.
1
25#ifndef JOIN_SERVICES_HTTP_PROTOCOL_HPP
26#define JOIN_SERVICES_HTTP_PROTOCOL_HPP
27
28// libjoin.
29#include <join/tls_protocol.hpp>
30
31namespace join
32{
33 template <class Protocol>
35
36 template <class Protocol>
38
39 template <class Protocol>
40 class BasicHttpWorker;
41
42 template <class Protocol>
43 class BasicHttpServer;
44
45 template <class Protocol>
47
51 class Http
52 {
53 public:
61
66 constexpr explicit Http (int family = AF_INET) noexcept
67 : _family (family)
68 {
69 }
70
75 static inline Http& v4 () noexcept
76 {
77 static Http httpv4 (AF_INET);
78 return httpv4;
79 }
80
85 static inline Http& v6 () noexcept
86 {
87 static Http httpv6 (AF_INET6);
88 return httpv6;
89 }
90
95 constexpr int family () const noexcept
96 {
97 return _family;
98 }
99
101 static constexpr uint16_t defaultPort = 80;
102
107 constexpr int type () const noexcept
108 {
109 return SOCK_STREAM;
110 }
111
116 constexpr int protocol () const noexcept
117 {
118 return IPPROTO_TCP;
119 }
120
121 private:
123 int _family;
124 };
125
132 constexpr bool operator== (const Http& a, const Http& b) noexcept
133 {
134 return a.family () == b.family ();
135 }
136
140 class Https
141 {
142 public:
143 using Transport = Tcp;
151
156 constexpr explicit Https (int family = AF_INET) noexcept
157 : _transport (family)
158 {
159 }
160
165 static inline Https& v4 () noexcept
166 {
167 static Https httpsv4 (AF_INET);
168 return httpsv4;
169 }
170
175 static inline Https& v6 () noexcept
176 {
177 static Https httpsv6 (AF_INET6);
178 return httpsv6;
179 }
180
185 constexpr int family () const noexcept
186 {
187 return _transport.family ();
188 }
189
191 static constexpr uint16_t defaultPort = 443;
192
193 private:
195 Transport _transport;
196 };
197
204 constexpr bool operator== (const Https& a, const Https& b) noexcept
205 {
206 return a.family () == b.family ();
207 }
208}
209
210#endif
basic HTTP client.
Definition http_protocol.hpp:34
basic HTTPS client.
Definition http_protocol.hpp:37
basic HTTPS server.
Definition http_server.hpp:983
basic HTTP server.
Definition http_server.hpp:648
basic HTTP worker.
Definition http_server.hpp:85
basic internet endpoint class.
Definition endpoint.hpp:517
socket stream class.
Definition socket_stream.hpp:350
basic stream acceptor class.
Definition protocol.hpp:56
basic stream socket class.
Definition stream_socket.hpp:44
TLS stream class.
Definition tls_stream.hpp:43
TLS decorator for stream sockets.
Definition tls_wrapper.hpp:38
HTTP protocol class (HTTP over TCP).
Definition http_protocol.hpp:52
constexpr int protocol() const noexcept
get the protocol type.
Definition http_protocol.hpp:116
static constexpr uint16_t defaultPort
default HTTP port.
Definition http_protocol.hpp:101
constexpr Http(int family=AF_INET) noexcept
construct the HTTP protocol instance.
Definition http_protocol.hpp:66
static Http & v4() noexcept
get protocol suitable for IPv4 address family.
Definition http_protocol.hpp:75
static Http & v6() noexcept
get protocol suitable for IPv6 address family.
Definition http_protocol.hpp:85
constexpr int type() const noexcept
get the protocol communication semantic.
Definition http_protocol.hpp:107
constexpr int family() const noexcept
get the protocol IP address family.
Definition http_protocol.hpp:95
HTTPS protocol class (HTTP over TLS).
Definition http_protocol.hpp:141
constexpr int family() const noexcept
get the protocol IP address family.
Definition http_protocol.hpp:185
typename Transport::Endpoint Endpoint
Definition http_protocol.hpp:144
typename Transport::Acceptor Acceptor
Definition http_protocol.hpp:147
static Https & v6() noexcept
get protocol suitable for IPv6 address family.
Definition http_protocol.hpp:175
static Https & v4() noexcept
get protocol suitable for IPv4 address family.
Definition http_protocol.hpp:165
constexpr Https(int family=AF_INET) noexcept
construct the HTTPS protocol instance.
Definition http_protocol.hpp:156
static constexpr uint16_t defaultPort
default HTTPS port.
Definition http_protocol.hpp:191
TCP protocol class.
Definition protocol.hpp:452
constexpr int family() const noexcept
get the protocol IP address family.
Definition protocol.hpp:494
BasicStreamAcceptor< Tcp > Acceptor
Definition protocol.hpp:457
BasicInternetEndpoint< Tcp > Endpoint
Definition protocol.hpp:454
Definition acceptor.hpp:32
bool operator==(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
compare if endpoints are equal.
Definition endpoint.hpp:196