Skip to content

Commit 2479a59

Browse files
committed
core - move stream frames into the connection for send
1 parent 1818ac1 commit 2479a59

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/http2/core/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
// You should have received a copy of the GNU General Public License
1616
// along with Osmium. If not, see <http://www.gnu.org/licenses/>.
1717

18+
// TODO rename this module to connection or similar.
19+
1820
mod connection_frame_state;
1921

2022
// std
@@ -150,6 +152,11 @@ impl<'a, 'b> Connection<'a, 'b> {
150152
if let Some(err) = stream_response {
151153
error!("Error on stream {}. The error was {:?}", frame.header.stream_id, err);
152154
}
155+
156+
// TODO does the stream build its error or does the error frame get built and sent here.
157+
158+
// Fetch any send frames which have been generated on the stream.
159+
self.send_frames.extend(stream.fetch_send_frames());
153160
},
154161
_ => {
155162
panic!("can't handle that frame type yet");
@@ -173,6 +180,7 @@ impl<'a, 'b> Connection<'a, 'b> {
173180
self.push_send_frame(Box::new(go_away), 0x0);
174181
}
175182

183+
// TODO do a fetch all like in stream?
176184
pub fn pull_frame(&mut self) -> Option<Vec<u8>> {
177185
self.send_frames.pop_front()
178186
}

src/http2/net/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ impl<T, R, S> Server<T, R, S>
7676

7777
let server_instance = Arc::new(Box::new(self));
7878

79+
// TODO the code below means that all streams run on the same thread. Probably
80+
// not the way it should be.
81+
7982
// get a stream (infinite iterator) of incoming connections
8083
let server = listener.incoming().zip(stream::repeat(server_instance.clone())).for_each(|((socket, _remote_addr), server_instance)| {
8184
debug!("Starting connection on {}", _remote_addr);

src/http2/stream/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ impl Stream {
546546
opt_err
547547
}
548548

549-
pub fn send(&mut self, frames: Vec<Box<framing::CompressibleHttpFrame>>) {
549+
fn send(&mut self, frames: Vec<Box<framing::CompressibleHttpFrame>>) {
550550
let mut temp_send_frames = Vec::new();
551551

552552
let mut frame_iter = frames.into_iter();
@@ -724,6 +724,10 @@ impl Stream {
724724
self.send_frames.extend(temp_send_frames);
725725
}
726726

727+
pub fn fetch_send_frames(&mut self) -> Vec<Vec<u8>> {
728+
self.send_frames.drain(1..).collect()
729+
}
730+
727731
fn should_headers_frame_end_stream(&self) -> bool {
728732
// If the request headers have already been received, but another headers frame is
729733
// being processed then is must end the stream.

0 commit comments

Comments
 (0)