Skip to content

Commit 76bd21f

Browse files
committed
code refactor
1 parent d7c1781 commit 76bd21f

20 files changed

+62
-62
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ configure_file(cmakeconfig.h.in config.h)
179179
set(ASIO_SV_SOURCES
180180
asio_common.cc
181181
asio_io_service_pool.cc
182-
asio_server_http2.cc
183-
asio_server_http2_impl.cc
182+
asio_server_httpx.cc
183+
asio_server_httpx_impl.cc
184184
asio_server.cc
185185
asio_server_http2_handler.cc
186186
asio_server_request.cc

H2Server_Request_Message.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <vector>
77
#include <list>
88
#include <map>
9-
#include <nghttp2/asio_http2_server.h>
9+
#include <nghttp2/asio_httpx_server.h>
1010
#include "asio_server_response.h"
1111
#include "asio_server_request.h"
1212

asio_server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
#include <boost/noncopyable.hpp>
4747

48-
#include <nghttp2/asio_http2_server.h>
48+
#include <nghttp2/asio_httpx_server.h>
4949

5050
#include "asio_io_service_pool.h"
5151
#include "H2Server_Config_Schema.h"

asio_server_base_handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <boost/array.hpp>
1212

13-
#include <nghttp2/asio_http2_server.h>
13+
#include <nghttp2/asio_httpx_server.h>
1414

1515
namespace nghttp2
1616
{

asio_server_connection.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include <boost/noncopyable.hpp>
4545
#include <boost/array.hpp>
4646

47-
#include <nghttp2/asio_http2_server.h>
47+
#include <nghttp2/asio_httpx_server.h>
4848

4949
#include "asio_server_http2_handler.h"
5050
#include "asio_server_http1_handler.h"

asio_server_http1_handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include <boost/array.hpp>
1313

14-
#include <nghttp2/asio_http2_server.h>
14+
#include <nghttp2/asio_httpx_server.h>
1515
#include "asio_server_base_handler.h"
1616

1717
#include "llhttp.h"

asio_server_http2_handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#include <boost/array.hpp>
3636

37-
#include <nghttp2/asio_http2_server.h>
37+
#include <nghttp2/asio_httpx_server.h>
3838
#include "asio_server_base_handler.h"
3939

4040
namespace nghttp2 {

asio_server_http2.cc renamed to asio_server_httpx.cc

+17-17
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
*/
2525
#include "nghttp2_config.h"
2626

27-
#include <nghttp2/asio_http2_server.h>
27+
#include <nghttp2/asio_httpx_server.h>
2828

29-
#include "asio_server_http2_impl.h"
29+
#include "asio_server_httpx_impl.h"
3030
#include "asio_server.h"
3131
#include "template.h"
3232

@@ -36,13 +36,13 @@ namespace asio_http2 {
3636

3737
namespace server {
3838

39-
http2::http2(const H2Server_Config_Schema& conf) : impl_(std::make_unique<http2_impl>(conf)) {}
39+
asio_httpx_server::asio_httpx_server(const H2Server_Config_Schema& conf) : impl_(std::make_unique<asio_server_httpx_impl>(conf)) {}
4040

41-
http2::~http2() {}
41+
asio_httpx_server::~asio_httpx_server() {}
4242

43-
http2::http2(http2 &&other) noexcept : impl_(std::move(other.impl_)) {}
43+
asio_httpx_server::asio_httpx_server(asio_httpx_server &&other) noexcept : impl_(std::move(other.impl_)) {}
4444

45-
http2 &http2::operator=(http2 &&other) noexcept {
45+
asio_httpx_server &asio_httpx_server::operator=(asio_httpx_server &&other) noexcept {
4646
if (this == &other) {
4747
return *this;
4848
}
@@ -52,45 +52,45 @@ http2 &http2::operator=(http2 &&other) noexcept {
5252
return *this;
5353
}
5454

55-
boost::system::error_code http2::listen_and_serve(boost::system::error_code &ec,
55+
boost::system::error_code asio_httpx_server::listen_and_serve(boost::system::error_code &ec,
5656
const std::string &address,
5757
const std::string &port,
5858
bool asynchronous) {
5959
return impl_->listen_and_serve(ec, nullptr, address, port, asynchronous);
6060
}
6161

62-
boost::system::error_code http2::listen_and_serve(
62+
boost::system::error_code asio_httpx_server::listen_and_serve(
6363
boost::system::error_code &ec, boost::asio::ssl::context &tls_context,
6464
const std::string &address, const std::string &port, bool asynchronous) {
6565
return impl_->listen_and_serve(ec, &tls_context, address, port, asynchronous);
6666
}
6767

68-
void http2::num_threads(size_t num_threads) { impl_->num_threads(num_threads); }
68+
void asio_httpx_server::num_threads(size_t num_threads) { impl_->num_threads(num_threads); }
6969

70-
void http2::backlog(int backlog) { impl_->backlog(backlog); }
70+
void asio_httpx_server::backlog(int backlog) { impl_->backlog(backlog); }
7171

72-
void http2::tls_handshake_timeout(const boost::posix_time::time_duration &t) {
72+
void asio_httpx_server::tls_handshake_timeout(const boost::posix_time::time_duration &t) {
7373
impl_->tls_handshake_timeout(t);
7474
}
7575

76-
void http2::read_timeout(const boost::posix_time::time_duration &t) {
76+
void asio_httpx_server::read_timeout(const boost::posix_time::time_duration &t) {
7777
impl_->read_timeout(t);
7878
}
7979

80-
bool http2::handle(std::string pattern, request_cb cb) {
80+
bool asio_httpx_server::handle(std::string pattern, request_cb cb) {
8181
return impl_->handle(std::move(pattern), std::move(cb));
8282
}
8383

84-
void http2::stop() { impl_->stop(); }
84+
void asio_httpx_server::stop() { impl_->stop(); }
8585

86-
void http2::join() { return impl_->join(); }
86+
void asio_httpx_server::join() { return impl_->join(); }
8787

8888
const std::vector<std::shared_ptr<boost::asio::io_service>> &
89-
http2::io_services() const {
89+
asio_httpx_server::io_services() const {
9090
return impl_->io_services();
9191
}
9292

93-
std::vector<int> http2::ports() const { return impl_->ports(); }
93+
std::vector<int> asio_httpx_server::ports() const { return impl_->ports(); }
9494

9595
} // namespace server
9696

asio_server_http2_impl.cc renamed to asio_server_httpx_impl.cc

+12-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2323
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2424
*/
25-
#include "asio_server_http2_impl.h"
25+
#include "asio_server_httpx_impl.h"
2626

2727
#include <openssl/ssl.h>
2828

@@ -37,14 +37,14 @@ namespace asio_http2 {
3737

3838
namespace server {
3939

40-
http2_impl::http2_impl(const H2Server_Config_Schema& conf)
40+
asio_server_httpx_impl::asio_server_httpx_impl(const H2Server_Config_Schema& conf)
4141
: num_threads_(1),
4242
backlog_(-1),
4343
tls_handshake_timeout_(boost::posix_time::seconds(60)),
4444
read_timeout_(boost::posix_time::seconds(60)),
4545
config(conf){}
4646

47-
boost::system::error_code http2_impl::listen_and_serve(
47+
boost::system::error_code asio_server_httpx_impl::listen_and_serve(
4848
boost::system::error_code &ec, boost::asio::ssl::context *tls_context,
4949
const std::string &address, const std::string &port, bool asynchronous) {
5050
server_.reset(
@@ -53,33 +53,33 @@ boost::system::error_code http2_impl::listen_and_serve(
5353
mux_, asynchronous);
5454
}
5555

56-
void http2_impl::num_threads(size_t num_threads) { num_threads_ = num_threads; }
56+
void asio_server_httpx_impl::num_threads(size_t num_threads) { num_threads_ = num_threads; }
5757

58-
void http2_impl::backlog(int backlog) { backlog_ = backlog; }
58+
void asio_server_httpx_impl::backlog(int backlog) { backlog_ = backlog; }
5959

60-
void http2_impl::tls_handshake_timeout(
60+
void asio_server_httpx_impl::tls_handshake_timeout(
6161
const boost::posix_time::time_duration &t) {
6262
tls_handshake_timeout_ = t;
6363
}
6464

65-
void http2_impl::read_timeout(const boost::posix_time::time_duration &t) {
65+
void asio_server_httpx_impl::read_timeout(const boost::posix_time::time_duration &t) {
6666
read_timeout_ = t;
6767
}
6868

69-
bool http2_impl::handle(std::string pattern, request_cb cb) {
69+
bool asio_server_httpx_impl::handle(std::string pattern, request_cb cb) {
7070
return mux_.handle(std::move(pattern), std::move(cb));
7171
}
7272

73-
void http2_impl::stop() { return server_->stop(); }
73+
void asio_server_httpx_impl::stop() { return server_->stop(); }
7474

75-
void http2_impl::join() { return server_->join(); }
75+
void asio_server_httpx_impl::join() { return server_->join(); }
7676

7777
const std::vector<std::shared_ptr<boost::asio::io_service>> &
78-
http2_impl::io_services() const {
78+
asio_server_httpx_impl::io_services() const {
7979
return server_->io_services();
8080
}
8181

82-
std::vector<int> http2_impl::ports() const { return server_->ports(); }
82+
std::vector<int> asio_server_httpx_impl::ports() const { return server_->ports(); }
8383

8484
} // namespace server
8585

asio_server_http2_impl.h renamed to asio_server_httpx_impl.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "nghttp2_config.h"
2929

30-
#include <nghttp2/asio_http2_server.h>
30+
#include <nghttp2/asio_httpx_server.h>
3131

3232
#include "asio_server_serve_mux.h"
3333
#include "H2Server_Config_Schema.h"
@@ -40,9 +40,9 @@ namespace server {
4040

4141
class server;
4242

43-
class http2_impl {
43+
class asio_server_httpx_impl {
4444
public:
45-
http2_impl(const H2Server_Config_Schema& conf);
45+
asio_server_httpx_impl(const H2Server_Config_Schema& conf);
4646
boost::system::error_code listen_and_serve(
4747
boost::system::error_code &ec, boost::asio::ssl::context *tls_context,
4848
const std::string &address, const std::string &port, bool asynchronous);

asio_server_request.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "nghttp2_config.h"
2929

30-
#include <nghttp2/asio_http2_server.h>
30+
#include <nghttp2/asio_httpx_server.h>
3131
#include <boost/asio/ip/tcp.hpp>
3232

3333
namespace nghttp2 {

asio_server_request_handler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727

2828
#include "nghttp2_config.h"
2929

30-
#include <nghttp2/asio_http2_server.h>
30+
#include <nghttp2/asio_httpx_server.h>
3131

3232
#endif // ASIO_SERVER_REQUEST_HANDLER_H

asio_server_response.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "nghttp2_config.h"
2929

30-
#include <nghttp2/asio_http2_server.h>
30+
#include <nghttp2/asio_httpx_server.h>
3131

3232
namespace nghttp2 {
3333
namespace asio_http2 {

asio_server_serve_mux.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "nghttp2_config.h"
2929

30-
#include <nghttp2/asio_http2_server.h>
30+
#include <nghttp2/asio_httpx_server.h>
3131

3232
namespace nghttp2 {
3333

asio_server_stream.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "nghttp2_config.h"
2929

30-
#include <nghttp2/asio_http2_server.h>
30+
#include <nghttp2/asio_httpx_server.h>
3131
#include "asio_server_request.h"
3232
#include "asio_server_response.h"
3333

asio_server_tls_context.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727

2828
#include "nghttp2_config.h"
2929

30-
#include <nghttp2/asio_http2_server.h>
30+
#include <nghttp2/asio_httpx_server.h>
3131

3232
#endif // ASIO_SERVER_TLS_CONTEXT_H

asio_util.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ void asio_svr_entry(const H2Server_Config_Schema& config_schema,
273273
}
274274
}
275275

276-
nghttp2::asio_http2::server::http2 server(config_schema);
276+
nghttp2::asio_http2::server::asio_httpx_server server(config_schema);
277277

278278
get_h2_server_instance(ss.str())->second = &server;
279279

@@ -660,9 +660,9 @@ void install_request_callback(const std::string& bootstrap_thread_id, size_t ser
660660
}
661661
}
662662

663-
std::map<std::string, nghttp2::asio_http2::server::http2*>::iterator get_h2_server_instance(const std::string& thread_id)
663+
std::map<std::string, nghttp2::asio_http2::server::asio_httpx_server*>::iterator get_h2_server_instance(const std::string& thread_id)
664664
{
665-
static std::map<std::string, nghttp2::asio_http2::server::http2*> h2_servers;
665+
static std::map<std::string, nghttp2::asio_http2::server::asio_httpx_server*> h2_servers;
666666
static std::mutex map_mutex;
667667
if (h2_servers.count(thread_id) == 0)
668668
{

asio_util.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <boost/asio/io_service.hpp>
1616
#include <boost/thread/thread.hpp>
1717

18-
#include <nghttp2/asio_http2_server.h>
18+
#include <nghttp2/asio_httpx_server.h>
1919
#include "asio_server_base_handler.h"
2020
#include "asio_server_stream.h"
2121

@@ -76,7 +76,7 @@ void asio_svr_entry(const H2Server_Config_Schema& config_schema,
7676

7777
std::vector<H2Server>& get_H2Server_match_Instances(const std::string& thread_id);
7878

79-
std::map<std::string, nghttp2::asio_http2::server::http2*>::iterator get_h2_server_instance(const std::string& thread_id);
79+
std::map<std::string, nghttp2::asio_http2::server::asio_httpx_server*>::iterator get_h2_server_instance(const std::string& thread_id);
8080

8181
bool init_H2Server_match_Instances(std::size_t number_of_instances, const std::string& config_schema);
8282

h2load_utils.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern "C" {
3232
#include "config_schema.h"
3333
#include "tls.h"
3434

35-
#include <nghttp2/asio_http2_server.h>
35+
#include <nghttp2/asio_httpx_server.h>
3636

3737
#include "h2load_utils.h"
3838
#include "base_client.h"
@@ -1533,7 +1533,7 @@ void integrated_http2_server(std::stringstream& dataStream, h2load::Config& conf
15331533
std::cerr << "builtin server listening at port: " << serverPort << std::endl;
15341534
H2Server_Config_Schema config_schema;
15351535

1536-
nghttp2::asio_http2::server::http2 server(config_schema);
1536+
nghttp2::asio_http2::server::asio_httpx_server server(config_schema);
15371537
boost::system::error_code ec;
15381538
server.num_threads(1);
15391539
server.handle("/stat", [&](const nghttp2::asio_http2::server::asio_server_request & req,

includes/nghttp2/asio_http2_server.h renamed to includes/nghttp2/asio_httpx_server.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ class asio_server_response;
4444
// the application must not access to those objects.
4545
typedef std::function<void(const asio_server_request&, asio_server_response&, uint64_t, int32_t)> request_cb;
4646

47-
class http2_impl;
47+
class asio_server_httpx_impl;
4848

49-
class http2 {
49+
class asio_httpx_server {
5050
public:
51-
http2(const H2Server_Config_Schema& conf);
52-
~http2();
51+
asio_httpx_server(const H2Server_Config_Schema& conf);
52+
~asio_httpx_server();
5353

54-
http2(http2 &&other) noexcept;
55-
http2 &operator=(http2 &&other) noexcept;
54+
asio_httpx_server(asio_httpx_server &&other) noexcept;
55+
asio_httpx_server &operator=(asio_httpx_server &&other) noexcept;
5656

5757
// Starts listening connection on given address and port and serves
5858
// incoming requests in cleartext TCP connection. If |asynchronous|
@@ -120,10 +120,10 @@ class http2 {
120120
// Sets read timeout, which defaults to 60 seconds.
121121
void read_timeout(const boost::posix_time::time_duration &t);
122122

123-
// Gracefully stop http2 server
123+
// Gracefully stop asio_httpx_server server
124124
void stop();
125125

126-
// Join on http2 server and wait for it to fully stop
126+
// Join on asio_httpx_server server and wait for it to fully stop
127127
void join();
128128

129129
// Get access to the io_service objects.
@@ -134,7 +134,7 @@ class http2 {
134134
std::vector<int> ports() const;
135135

136136
private:
137-
std::unique_ptr<http2_impl> impl_;
137+
std::unique_ptr<asio_server_httpx_impl> impl_;
138138
};
139139

140140
// Configures |tls_context| for server use. This function sets couple

0 commit comments

Comments
 (0)