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
143 constexpr bool operator!= (const Http& a, const Http& b) noexcept
144 {
145 return !(a == b);
146 }
147
151 class Https
152 {
153 public:
154 using Transport = Tcp;
162
167 constexpr explicit Https (int family = AF_INET) noexcept
168 : _transport (family)
169 {
170 }
171
176 static inline Https& v4 () noexcept
177 {
178 static Https httpsv4 (AF_INET);
179 return httpsv4;
180 }
181
186 static inline Https& v6 () noexcept
187 {
188 static Https httpsv6 (AF_INET6);
189 return httpsv6;
190 }
191
196 constexpr int family () const noexcept
197 {
198 return _transport.family ();
199 }
200
202 static constexpr uint16_t defaultPort = 443;
203
204 private:
206 Transport _transport;
207 };
208
215 constexpr bool operator== (const Https& a, const Https& b) noexcept
216 {
217 return a.family () == b.family ();
218 }
219
226 constexpr bool operator!= (const Https& a, const Https& b) noexcept
227 {
228 return !(a == b);
229 }
230}
231
232#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:632
socket stream class.
Definition socket_stream.hpp:350
basic stream acceptor class.
Definition protocol.hpp:53
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:152
constexpr int family() const noexcept
get the protocol IP address family.
Definition http_protocol.hpp:196
typename Transport::Endpoint Endpoint
Definition http_protocol.hpp:155
typename Transport::Acceptor Acceptor
Definition http_protocol.hpp:158
static Https & v6() noexcept
get protocol suitable for IPv6 address family.
Definition http_protocol.hpp:186
static Https & v4() noexcept
get protocol suitable for IPv4 address family.
Definition http_protocol.hpp:176
constexpr Https(int family=AF_INET) noexcept
construct the HTTPS protocol instance.
Definition http_protocol.hpp:167
static constexpr uint16_t defaultPort
default HTTPS port.
Definition http_protocol.hpp:202
TCP protocol class.
Definition protocol.hpp:471
constexpr int family() const noexcept
get the protocol IP address family.
Definition protocol.hpp:513
BasicStreamAcceptor< Tcp > Acceptor
Definition protocol.hpp:476
BasicInternetEndpoint< Tcp > Endpoint
Definition protocol.hpp:473
Definition acceptor.hpp:32
bool operator==(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
compare if endpoints are equal.
Definition endpoint.hpp:186
bool operator!=(const BasicLinkLayerEndpoint< Protocol > &a, const BasicLinkLayerEndpoint< Protocol > &b) noexcept
compare if endpoints are not equal.
Definition endpoint.hpp:198