Repository navigation
Expand file tree
/
Copy pathhttp1_host.hpp
More file actions
45 lines (41 loc) · 1.9 KB
/
Copy pathhttp1_host.hpp
File metadata and controls
45 lines (41 loc) · 1.9 KB
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
/*
This file is part of libhttpserver
Copyright (C) 2011-2026 Sebastiano Merlino
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the file
LICENSE in the distribution; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#ifndef SRC_HTTPSERVER_DETAIL_HTTP1_HOST_HPP_
#define SRC_HTTPSERVER_DETAIL_HTTP1_HOST_HPP_
#include <string_view>
#include <httpserver/detail/http1_target.hpp>
#include <httpserver/http/request_head.hpp>
#include <httpserver/net/address.hpp>
namespace httpserver::detail {
// RFC 9112 section 3.2: routing may start only after Host cardinality
// and authority syntax are checked. An empty Host is legal for a target
// without an authority; duplicate Host is never unambiguous.
namespace http1_host {
inline bool alphanumeric(char c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9');
}
bool name_character(char c);
bool reg_name(std::string_view name);
bool future_literal(std::string_view literal);
bool ip_literal(std::string_view literal);
bool port(std::string_view value);
} // namespace http1_host
bool valid_http1_host(std::string_view host);
bool valid_http1_host(const http::request_head& head);
} // namespace httpserver::detail
#endif // SRC_HTTPSERVER_DETAIL_HTTP1_HOST_HPP_