Sese Framework
x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
HttpServiceImpl.h
浏览该文件的文档.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#pragma once
16
17
#include <optional>
18
#include <
sese/service/http/HttpService.h
>
19
20
#include <
sese/internal/service/http/HttpConnection.h
>
21
#include <
sese/internal/service/http/HttpConnectionEx.h
>
22
23
namespace
sese::internal::service::http
{
24
26
class
HttpServiceImpl
final :
public
sese::service::http::HttpService
,
27
public
std::enable_shared_from_this<HttpServiceImpl> {
28
public
:
29
friend
struct
HttpConnection
;
30
friend
struct
HttpConnectionEx
;
31
32
HttpServiceImpl
(
33
const
sese::net::IPAddress::Ptr
&
address
,
34
SSLContextPtr
ssl_context
,
35
uint32_t
keepalive
,
36
std::string &
serv_name
,
37
MountPointMap
&
mount_points
,
38
ServletMap
&
servlets
,
39
FilterCallback
&
tail_filter
,
40
FilterMap
&
filters
,
41
ConnectionCallback
&
connection_callback
42
);
43
44
bool
startup
()
override
;
45
46
bool
shutdown
()
override
;
47
48
int
getLastError
()
override
;
49
50
std::string
getLastErrorMessage
()
override
;
51
52
uint32_t
getKeepalive
()
const
{
return
keepalive
; }
53
54
void
handleFilter
(
const
Handleable::Ptr
&conn)
const
;
55
56
void
handleRequest
(
const
Handleable::Ptr
&conn)
const
;
57
58
private
:
59
asio::io_context
io_context
;
60
std::optional<asio::ssl::context>
ssl_context
;
61
asio::ip::tcp::acceptor
acceptor
;
62
asio::error_code
error
;
63
64
static
constexpr
unsigned
char
ALPN_PROTOS
[] =
"\x2h2\x8http/1.1"
;
65
66
static
int
alpnCallback
(SSL *ssl,
const
uint8_t **out, uint8_t *out_length,
const
uint8_t *
in
, uint32_t in_length,
void
*data);
67
68
void
handleAccept
();
69
70
void
handleSSLAccept
();
71
72
std::set<HttpConnection::Ptr>
connections
;
73
std::set<HttpConnectionEx::Ptr>
connections2
;
74
};
75
76
}
sese
internal
service
http
HttpServiceImpl.h
生成于 2024年 十一月 4日 星期一 09:58:00 , 为 Sese Framework使用
1.11.0