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
a1402974
Commit
a1402974
authored
Mar 04, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asio:: Add cancel() and on_close() to server::response
parent
7e46d0b1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
+34
-0
src/asio_http2_handler.cc
src/asio_http2_handler.cc
+25
-0
src/asio_http2_handler.h
src/asio_http2_handler.h
+5
-0
src/includes/nghttp2/asio_http2_server.h
src/includes/nghttp2/asio_http2_server.h
+4
-0
No files found.
src/asio_http2_handler.cc
View file @
a1402974
...
@@ -63,6 +63,10 @@ void response::end(std::string data) const { impl_->end(std::move(data)); }
...
@@ -63,6 +63,10 @@ void response::end(std::string data) const { impl_->end(std::move(data)); }
void
response
::
end
(
read_cb
cb
)
const
{
impl_
->
end
(
std
::
move
(
cb
));
}
void
response
::
end
(
read_cb
cb
)
const
{
impl_
->
end
(
std
::
move
(
cb
));
}
void
response
::
on_close
(
close_cb
cb
)
const
{
impl_
->
on_close
(
std
::
move
(
cb
));
}
void
response
::
cancel
()
const
{
impl_
->
cancel
();
}
const
response
*
response
::
push
(
boost
::
system
::
error_code
&
ec
,
const
response
*
response
::
push
(
boost
::
system
::
error_code
&
ec
,
std
::
string
method
,
std
::
string
path
,
std
::
string
method
,
std
::
string
path
,
header_map
h
)
const
{
header_map
h
)
const
{
...
@@ -133,6 +137,20 @@ void response_impl::end(read_cb cb) {
...
@@ -133,6 +137,20 @@ void response_impl::end(read_cb cb) {
start_response
();
start_response
();
}
}
void
response_impl
::
on_close
(
close_cb
cb
)
{
close_cb_
=
std
::
move
(
cb
);
}
void
response_impl
::
call_on_close
(
uint32_t
error_code
)
{
if
(
close_cb_
)
{
close_cb_
(
error_code
);
}
}
void
response_impl
::
cancel
()
{
auto
handler
=
stream_
->
handler
();
handler
->
stream_error
(
stream_
->
get_stream_id
(),
NGHTTP2_CANCEL
);
}
void
response_impl
::
start_response
()
{
void
response_impl
::
start_response
()
{
if
(
!
started_
||
(
pushed_
&&
!
push_promise_sent_
))
{
if
(
!
started_
||
(
pushed_
&&
!
push_promise_sent_
))
{
return
;
return
;
...
@@ -333,6 +351,13 @@ int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
...
@@ -333,6 +351,13 @@ int on_stream_close_callback(nghttp2_session *session, int32_t stream_id,
uint32_t
error_code
,
void
*
user_data
)
{
uint32_t
error_code
,
void
*
user_data
)
{
auto
handler
=
static_cast
<
http2_handler
*>
(
user_data
);
auto
handler
=
static_cast
<
http2_handler
*>
(
user_data
);
auto
stream
=
handler
->
find_stream
(
stream_id
);
if
(
!
stream
)
{
return
0
;
}
stream
->
response
().
impl
().
call_on_close
(
error_code
);
handler
->
close_stream
(
stream_id
);
handler
->
close_stream
(
stream_id
);
return
0
;
return
0
;
...
...
src/asio_http2_handler.h
View file @
a1402974
...
@@ -76,8 +76,11 @@ public:
...
@@ -76,8 +76,11 @@ public:
void
write_head
(
unsigned
int
status_code
,
header_map
h
=
{});
void
write_head
(
unsigned
int
status_code
,
header_map
h
=
{});
void
end
(
std
::
string
data
=
""
);
void
end
(
std
::
string
data
=
""
);
void
end
(
read_cb
cb
);
void
end
(
read_cb
cb
);
void
on_close
(
close_cb
cb
);
void
resume
();
void
resume
();
void
cancel
();
response
*
push
(
boost
::
system
::
error_code
&
ec
,
std
::
string
method
,
response
*
push
(
boost
::
system
::
error_code
&
ec
,
std
::
string
method
,
std
::
string
raw_path_query
,
header_map
h
=
{})
const
;
std
::
string
raw_path_query
,
header_map
h
=
{})
const
;
...
@@ -91,11 +94,13 @@ public:
...
@@ -91,11 +94,13 @@ public:
void
stream
(
http2_stream
*
s
);
void
stream
(
http2_stream
*
s
);
read_cb
::
result_type
call_read
(
uint8_t
*
data
,
std
::
size_t
len
,
read_cb
::
result_type
call_read
(
uint8_t
*
data
,
std
::
size_t
len
,
uint32_t
*
data_flags
);
uint32_t
*
data_flags
);
void
call_on_close
(
uint32_t
error_code
);
private:
private:
http2_stream
*
stream_
;
http2_stream
*
stream_
;
header_map
header_
;
header_map
header_
;
read_cb
read_cb_
;
read_cb
read_cb_
;
close_cb
close_cb_
;
unsigned
int
status_code_
;
unsigned
int
status_code_
;
// true if response started (end() is called)
// true if response started (end() is called)
bool
started_
;
bool
started_
;
...
...
src/includes/nghttp2/asio_http2_server.h
View file @
a1402974
...
@@ -78,6 +78,10 @@ public:
...
@@ -78,6 +78,10 @@ public:
// further call of end() is allowed.
// further call of end() is allowed.
void
end
(
read_cb
cb
)
const
;
void
end
(
read_cb
cb
)
const
;
void
on_close
(
close_cb
cb
)
const
;
void
cancel
()
const
;
// Resumes deferred response.
// Resumes deferred response.
void
resume
()
const
;
void
resume
()
const
;
...
...
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