-
-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement h2::server::Stream::send_reset(Reason) and Body::is_empty() #22
Changes from 12 commits
b237be9
7337e92
21e461e
2b649d8
b264666
c3e52c7
4da88e0
d599204
df65c2c
4e8e4c3
0bc9ca2
628b94a
7860b4d
6e3860b
f899a17
63bbafc
5f708ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use {frame, ConnectionError}; | ||
use error::User::InactiveStreamId; | ||
use proto::*; | ||
use super::*; | ||
|
||
|
@@ -107,6 +108,22 @@ impl<B> Send<B> where B: Buf { | |
stream.state.send_close() | ||
} | ||
|
||
pub fn send_reset(&mut self, reason: Reason, | ||
stream: &mut store::Ptr<B>) | ||
-> Result<(), ConnectionError> | ||
{ | ||
if stream.state.is_closed() { | ||
return Err(InactiveStreamId.into()) | ||
} | ||
|
||
stream.state.send_reset(reason)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the reset will still be sent if the stream state is already closed (potentially reset already). Is this expected? |
||
|
||
let frame = frame::Reset::new(stream.id, reason); | ||
self.prioritize.queue_frame(frame.into(), stream); | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn send_data(&mut self, | ||
frame: frame::Data<B>, | ||
stream: &mut store::Ptr<B>) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,6 +336,16 @@ impl<B> StreamRef<B> | |
me.actions.recv.take_request(&mut stream) | ||
} | ||
|
||
pub fn send_reset<P: Peer>(&mut self, reason: Reason) -> Result<(), ConnectionError> { | ||
let mut me = self.inner.lock().unwrap(); | ||
let me = &mut *me; | ||
|
||
let stream = me.store.resolve(self.key); | ||
me.actions.transition::<P, _, _>(stream, move |actions, stream| { | ||
actions.send.send_reset(reason, stream) | ||
}) | ||
} | ||
|
||
pub fn send_response(&mut self, response: Response<()>, end_of_stream: bool) | ||
-> Result<(), ConnectionError> | ||
{ | ||
|
@@ -352,6 +362,15 @@ impl<B> StreamRef<B> | |
}) | ||
} | ||
|
||
pub fn is_recv_eos(&self) -> bool { | ||
let mut me = self.inner.lock().unwrap(); | ||
let me = &mut *me; | ||
|
||
let stream = me.store.resolve(self.key); | ||
|
||
stream.state.is_recv_closed() && stream.pending_recv.is_empty() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it worth just tracking a bool for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, i think this is okay if it's only meant to determine whether eos may be set... |
||
} | ||
|
||
pub fn poll_response(&mut self) -> Poll<Response<()>, ConnectionError> { | ||
let mut me = self.inner.lock().unwrap(); | ||
let me = &mut *me; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per the comment thread below, this will return
false
if the body is consumed and the next pending frame is a trailer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that's correct fsvo is_empty. I intend to expose "is there a body at all" and not "is there remaining body to be consumed". i should probably rename this