Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
35817876
Commit
35817876
authored
Mar 04, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asio: Move server API to asio_http2_server.h
parent
7d753d77
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
174 additions
and
143 deletions
+174
-143
examples/asio-sv.cc
examples/asio-sv.cc
+1
-1
examples/asio-sv2.cc
examples/asio-sv2.cc
+1
-1
src/asio_connection.h
src/asio_connection.h
+2
-2
src/asio_http2_handler.h
src/asio_http2_handler.h
+2
-4
src/asio_http2_impl.cc
src/asio_http2_impl.cc
+0
-4
src/asio_http2_impl.h
src/asio_http2_impl.h
+1
-1
src/asio_io_service_pool.h
src/asio_io_service_pool.h
+2
-2
src/asio_server.h
src/asio_server.h
+2
-3
src/includes/Makefile.am
src/includes/Makefile.am
+2
-1
src/includes/nghttp2/asio_http2.h
src/includes/nghttp2/asio_http2.h
+1
-122
src/includes/nghttp2/asio_http2_client.h
src/includes/nghttp2/asio_http2_client.h
+0
-2
src/includes/nghttp2/asio_http2_server.h
src/includes/nghttp2/asio_http2_server.h
+160
-0
No files found.
examples/asio-sv.cc
View file @
35817876
...
...
@@ -37,7 +37,7 @@
#include <iostream>
#include <string>
#include <nghttp2/asio_http2.h>
#include <nghttp2/asio_http2
_server
.h>
using
namespace
nghttp2
::
asio_http2
;
using
namespace
nghttp2
::
asio_http2
::
server
;
...
...
examples/asio-sv2.cc
View file @
35817876
...
...
@@ -40,7 +40,7 @@
#include <iostream>
#include <string>
#include <nghttp2/asio_http2.h>
#include <nghttp2/asio_http2
_server
.h>
using
namespace
nghttp2
::
asio_http2
;
using
namespace
nghttp2
::
asio_http2
::
server
;
...
...
src/asio_connection.h
View file @
35817876
...
...
@@ -41,11 +41,11 @@
#include <memory>
#include <boost/asio.hpp>
#include <boost/noncopyable.hpp>
#include <boost/array.hpp>
#include <nghttp2/asio_http2.h>
#include <nghttp2/asio_http2_server.h>
#include "asio_http2_handler.h"
#include "util.h"
...
...
src/asio_http2_handler.h
View file @
35817876
...
...
@@ -31,12 +31,10 @@
#include <vector>
#include <functional>
#include <string>
#include <boost/array.hpp>
#include <boost/asio.hpp>
#include <
nghttp2/nghttp2.h
>
#include <
boost/array.hpp
>
#include <nghttp2/asio_http2.h>
#include <nghttp2/asio_http2
_server
.h>
namespace
nghttp2
{
namespace
asio_http2
{
...
...
src/asio_http2_impl.cc
View file @
35817876
...
...
@@ -24,12 +24,8 @@
*/
#include "asio_http2_impl.h"
#include <boost/asio/ssl.hpp>
#include <openssl/ssl.h>
#include <nghttp2/nghttp2.h>
#include "asio_server.h"
#include "util.h"
#include "ssl.h"
...
...
src/asio_http2_impl.h
View file @
35817876
...
...
@@ -27,7 +27,7 @@
#include "nghttp2_config.h"
#include <nghttp2/asio_http2.h>
#include <nghttp2/asio_http2
_server
.h>
namespace
nghttp2
{
...
...
src/asio_io_service_pool.h
View file @
35817876
...
...
@@ -41,11 +41,11 @@
#include <vector>
#include <memory>
#include <boost/asio.hpp>
#include <boost/noncopyable.hpp>
#include <boost/thread.hpp>
#include <nghttp2/asio_http2.h>
#include <nghttp2/asio_http2
_server
.h>
namespace
nghttp2
{
...
...
src/asio_server.h
View file @
35817876
...
...
@@ -42,11 +42,10 @@
#include <string>
#include <vector>
#include <memory>
#include <boost/noncopyable.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <nghttp2/asio_http2.h>
#include <nghttp2/asio_http2
_server
.h>
#include "asio_connection.h"
#include "asio_io_service_pool.h"
...
...
src/includes/Makefile.am
View file @
35817876
...
...
@@ -20,4 +20,5 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
nobase_include_HEADERS
=
nghttp2/asio_http2.h nghttp2/asio_http2_client.h
nobase_include_HEADERS
=
nghttp2/asio_http2.h nghttp2/asio_http2_client.h
\
nghttp2/asio_http2_server.h
src/includes/nghttp2/asio_http2.h
View file @
35817876
...
...
@@ -34,6 +34,7 @@
#include <boost/system/error_code.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include <nghttp2/nghttp2.h>
...
...
@@ -100,128 +101,6 @@ typedef std::function<void(uint32_t)> close_cb;
typedef
std
::
function
<
std
::
pair
<
ssize_t
,
bool
>
(
uint8_t
*
buf
,
std
::
size_t
len
)
>
read_cb
;
namespace
server
{
class
request_impl
;
class
response_impl
;
class
request
{
public:
// Application must not call this directly.
request
();
// Returns request headers. The pusedo headers, which start with
// colon (;), are exluced from this list.
const
std
::
vector
<
header
>
&
headers
()
const
;
// Returns method (e.g., GET).
const
std
::
string
&
method
()
const
;
// Returns scheme (e.g., https).
const
std
::
string
&
scheme
()
const
;
// Returns authority (e.g., example.org). This could be empty
// string. In this case, check host().
const
std
::
string
&
authority
()
const
;
// Returns host (e.g., example.org). If host header field is not
// present, this value is copied from authority().
const
std
::
string
&
host
()
const
;
// Returns path (e.g., /index.html).
const
std
::
string
&
path
()
const
;
// Sets callback when chunk of request body is received.
void
on_data
(
data_cb
cb
)
const
;
// Sets callback when request was completed.
void
on_end
(
void_cb
cb
)
const
;
// Pushes resource denoted by |path| using |method|. The additional
// headers can be given in |headers|. request_cb will be called for
// pushed resource later on. This function returns true if it
// succeeds, or false.
bool
push
(
std
::
string
method
,
std
::
string
path
,
std
::
vector
<
header
>
headers
=
{})
const
;
// Returns true if this is pushed request.
bool
pushed
()
const
;
// Application must not call this directly.
request_impl
&
impl
()
const
;
private:
std
::
unique_ptr
<
request_impl
>
impl_
;
};
class
response
{
public:
// Application must not call this directly.
response
();
// Write response header using |status_code| (e.g., 200) and
// additional headers in |headers|.
void
write_head
(
unsigned
int
status_code
,
std
::
vector
<
header
>
headers
=
{})
const
;
// Sends |data| as request body. No further call of end() is
// allowed.
void
end
(
std
::
string
data
=
""
)
const
;
// Sets callback |cb| as a generator of the response body. No
// further call of end() is allowed.
void
end
(
read_cb
cb
)
const
;
// Resumes deferred response.
void
resume
()
const
;
// Returns status code.
unsigned
int
status_code
()
const
;
// Returns true if response has been started.
bool
started
()
const
;
// Application must not call this directly.
response_impl
&
impl
()
const
;
private:
std
::
unique_ptr
<
response_impl
>
impl_
;
};
// This is so called request callback. Called every time request is
// received.
typedef
std
::
function
<
void
(
const
request
&
,
const
response
&
)
>
request_cb
;
class
http2_impl
;
class
http2
{
public:
http2
();
~
http2
();
// Starts listening connection on given address and port. The
// incoming requests are handled by given callback |cb|.
void
listen
(
const
std
::
string
&
address
,
uint16_t
port
,
request_cb
cb
);
// Sets number of native threads to handle incoming HTTP request.
// It defaults to 1.
void
num_threads
(
size_t
num_threads
);
// Sets TLS private key file and certificate file. Both files must
// be in PEM format.
void
tls
(
std
::
string
private_key_file
,
std
::
string
certificate_file
);
// Sets the maximum length to which the queue of pending
// connections.
void
backlog
(
int
backlog
);
private:
std
::
unique_ptr
<
http2_impl
>
impl_
;
};
}
// namespace server
// Convenient function to create function to read file denoted by
// |path|. This can be passed to response::end().
read_cb
file_reader
(
const
std
::
string
&
path
);
...
...
src/includes/nghttp2/asio_http2_client.h
View file @
35817876
...
...
@@ -27,8 +27,6 @@
#include <nghttp2/asio_http2.h>
#include <boost/asio/ssl.hpp>
namespace
nghttp2
{
namespace
asio_http2
{
...
...
src/includes/nghttp2/asio_http2_server.h
0 → 100644
View file @
35817876
/*
* nghttp2 - HTTP/2 C Library
*
* Copyright (c) 2015 Tatsuhiro Tsujikawa
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef ASIO_HTTP2_SERVER_H
#define ASIO_HTTP2_SERVER_H
#include <nghttp2/asio_http2.h>
namespace
nghttp2
{
namespace
asio_http2
{
namespace
server
{
class
request_impl
;
class
response_impl
;
class
request
{
public:
// Application must not call this directly.
request
();
// Returns request headers. The pusedo headers, which start with
// colon (;), are exluced from this list.
const
std
::
vector
<
header
>
&
headers
()
const
;
// Returns method (e.g., GET).
const
std
::
string
&
method
()
const
;
// Returns scheme (e.g., https).
const
std
::
string
&
scheme
()
const
;
// Returns authority (e.g., example.org). This could be empty
// string. In this case, check host().
const
std
::
string
&
authority
()
const
;
// Returns host (e.g., example.org). If host header field is not
// present, this value is copied from authority().
const
std
::
string
&
host
()
const
;
// Returns path (e.g., /index.html).
const
std
::
string
&
path
()
const
;
// Sets callback when chunk of request body is received.
void
on_data
(
data_cb
cb
)
const
;
// Sets callback when request was completed.
void
on_end
(
void_cb
cb
)
const
;
// Pushes resource denoted by |path| using |method|. The additional
// headers can be given in |headers|. request_cb will be called for
// pushed resource later on. This function returns true if it
// succeeds, or false.
bool
push
(
std
::
string
method
,
std
::
string
path
,
std
::
vector
<
header
>
headers
=
{})
const
;
// Returns true if this is pushed request.
bool
pushed
()
const
;
// Application must not call this directly.
request_impl
&
impl
()
const
;
private:
std
::
unique_ptr
<
request_impl
>
impl_
;
};
class
response
{
public:
// Application must not call this directly.
response
();
// Write response header using |status_code| (e.g., 200) and
// additional headers in |headers|.
void
write_head
(
unsigned
int
status_code
,
std
::
vector
<
header
>
headers
=
{})
const
;
// Sends |data| as request body. No further call of end() is
// allowed.
void
end
(
std
::
string
data
=
""
)
const
;
// Sets callback |cb| as a generator of the response body. No
// further call of end() is allowed.
void
end
(
read_cb
cb
)
const
;
// Resumes deferred response.
void
resume
()
const
;
// Returns status code.
unsigned
int
status_code
()
const
;
// Returns true if response has been started.
bool
started
()
const
;
// Application must not call this directly.
response_impl
&
impl
()
const
;
private:
std
::
unique_ptr
<
response_impl
>
impl_
;
};
// This is so called request callback. Called every time request is
// received.
typedef
std
::
function
<
void
(
const
request
&
,
const
response
&
)
>
request_cb
;
class
http2_impl
;
class
http2
{
public:
http2
();
~
http2
();
// Starts listening connection on given address and port. The
// incoming requests are handled by given callback |cb|.
void
listen
(
const
std
::
string
&
address
,
uint16_t
port
,
request_cb
cb
);
// Sets number of native threads to handle incoming HTTP request.
// It defaults to 1.
void
num_threads
(
size_t
num_threads
);
// Sets TLS private key file and certificate file. Both files must
// be in PEM format.
void
tls
(
std
::
string
private_key_file
,
std
::
string
certificate_file
);
// Sets the maximum length to which the queue of pending
// connections.
void
backlog
(
int
backlog
);
private:
std
::
unique_ptr
<
http2_impl
>
impl_
;
};
}
// namespace server
}
// namespace asio_http2
}
// namespace nghttp2
#endif // ASIO_HTTP2_SERVER_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment