Skip to content

Commit 2353f3d

Browse files
committed
Remove the Headers structure
1 parent 91d5beb commit 2353f3d

19 files changed

+210
-273
lines changed

neqo-common/src/headers.rs

-180
This file was deleted.

neqo-common/src/lib.rs

-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ mod codec;
1111
mod datagram;
1212
pub mod event;
1313
pub mod header;
14-
pub mod headers;
1514
pub mod hrtime;
1615
mod incrdecoder;
1716
pub mod log;
@@ -21,17 +20,10 @@ pub mod timer;
2120
pub use self::codec::{Decoder, Encoder};
2221
pub use self::datagram::Datagram;
2322
pub use self::header::Header;
24-
pub use self::headers::Headers;
2523
pub use self::incrdecoder::{
2624
IncrementalDecoderBuffer, IncrementalDecoderIgnore, IncrementalDecoderUint,
2725
};
2826

29-
type Res<T> = Result<T, Error>;
30-
31-
pub enum Error {
32-
InvalidHeader,
33-
}
34-
3527
#[macro_use]
3628
extern crate lazy_static;
3729

neqo-http3/src/client_events.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
features::extended_connect::{ExtendedConnectEvents, ExtendedConnectType},
1313
CloseType, Http3StreamInfo, HttpRecvStreamEvents, RecvStreamEvents, SendStreamEvents,
1414
};
15-
use neqo_common::{event::Provider as EventProvider, Headers};
15+
use neqo_common::{event::Provider as EventProvider, Header};
1616
use neqo_crypto::ResumptionToken;
1717
use neqo_transport::{AppError, StreamId, StreamType};
1818

@@ -39,7 +39,7 @@ pub enum Http3ClientEvent {
3939
/// Response headers are received.
4040
HeaderReady {
4141
stream_id: StreamId,
42-
headers: Headers,
42+
headers: Vec<Header>,
4343
interim: bool,
4444
fin: bool,
4545
},
@@ -62,12 +62,12 @@ pub enum Http3ClientEvent {
6262
PushPromise {
6363
push_id: u64,
6464
request_stream_id: StreamId,
65-
headers: Headers,
65+
headers: Vec<Header>,
6666
},
6767
/// A push response headers are ready.
6868
PushHeaderReady {
6969
push_id: u64,
70-
headers: Headers,
70+
headers: Vec<Header>,
7171
interim: bool,
7272
fin: bool,
7373
},
@@ -143,7 +143,7 @@ impl HttpRecvStreamEvents for Http3ClientEvents {
143143
fn header_ready(
144144
&self,
145145
stream_info: Http3StreamInfo,
146-
headers: Headers,
146+
headers: Vec<Header>,
147147
interim: bool,
148148
fin: bool,
149149
) {
@@ -210,7 +210,7 @@ impl ExtendedConnectEvents for Http3ClientEvents {
210210
}
211211

212212
impl Http3ClientEvents {
213-
pub fn push_promise(&self, push_id: u64, request_stream_id: StreamId, headers: Headers) {
213+
pub fn push_promise(&self, push_id: u64, request_stream_id: StreamId, headers: Vec<Header>) {
214214
self.insert(Http3ClientEvent::PushPromise {
215215
push_id,
216216
request_stream_id,

neqo-http3/src/connection.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ use crate::send_message::SendMessage;
2222
use crate::settings::{HSettingType, HSettings, HttpZeroRttChecker};
2323
use crate::stream_type_reader::NewStreamHeadReader;
2424
use crate::{
25-
client_events::Http3ClientEvents, CloseType, Header, Http3Parameters, Http3StreamType,
25+
client_events::Http3ClientEvents, CloseType, Http3Parameters, Http3StreamType,
2626
HttpRecvStreamEvents, NewStreamType, Priority, PriorityHandler, ReceiveOutput, RecvStream,
2727
RecvStreamEvents, SendStream, SendStreamEvents,
2828
};
29-
use neqo_common::{qdebug, qerror, qinfo, qtrace, qwarn, Headers, MessageType, Role};
29+
use neqo_common::{qdebug, qerror, qinfo, qtrace, qwarn, Header, MessageType, Role};
3030
use neqo_qpack::decoder::QPackDecoder;
3131
use neqo_qpack::encoder::QPackEncoder;
3232
use neqo_transport::{AppError, Connection, ConnectionError, State, StreamId, StreamType};
@@ -547,7 +547,7 @@ impl Http3Connection {
547547
output
548548
}
549549

550-
fn create_fetch_headers<'b, 't, T>(request: &RequestDescription<'b, 't, T>) -> Res<Headers>
550+
fn create_fetch_headers<'b, 't, T>(request: &RequestDescription<'b, 't, T>) -> Res<Vec<Header>>
551551
where
552552
T: AsRequestTarget<'t> + ?Sized + Debug,
553553
{
@@ -557,12 +557,12 @@ impl Http3Connection {
557557
.map_err(|_| Error::InvalidRequestTarget)?;
558558

559559
// Transform pseudo-header fields
560-
let mut final_headers = Headers::new(&[
560+
let mut final_headers = vec![
561561
Header::new(":method", request.method),
562562
Header::new(":scheme", target.scheme()),
563563
Header::new(":authority", target.authority()),
564564
Header::new(":path", target.path()),
565-
]);
565+
];
566566
if let Some(conn_type) = request.connect_type {
567567
final_headers.push(Header::new(":protocol", conn_type.string()));
568568
}
@@ -619,7 +619,7 @@ impl Http3Connection {
619619
send_message
620620
.http_stream()
621621
.unwrap()
622-
.send_headers(final_headers, conn)?;
622+
.send_headers(&final_headers, conn)?;
623623

624624
self.add_streams(
625625
id,
@@ -854,7 +854,7 @@ impl Http3Connection {
854854
(Some(s), Some(_r), false) => {
855855
if s.http_stream()
856856
.ok_or(Error::InvalidStreamId)?
857-
.send_headers(Headers::new(&[Header::new(":status", "400")]), conn)
857+
.send_headers(&[Header::new(":status", "400")], conn)
858858
.is_ok()
859859
{
860860
mem::drop(self.stream_close_send(conn, stream_id));
@@ -873,7 +873,7 @@ impl Http3Connection {
873873
(Some(s), Some(r), true) => {
874874
if s.http_stream()
875875
.ok_or(Error::InvalidStreamId)?
876-
.send_headers(Headers::new(&[Header::new(":status", "200")]), conn)
876+
.send_headers(&[Header::new(":status", "200")], conn)
877877
.is_ok()
878878
{
879879
let extended_conn = Rc::new(RefCell::new(ExtendedConnectSession::new(

neqo-http3/src/connection_client.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ use crate::recv_message::{RecvMessage, RecvMessageInfo};
1212
use crate::request_target::AsRequestTarget;
1313
use crate::settings::HSettings;
1414
use crate::{
15-
Header, Http3Parameters, Http3StreamType, NewStreamType, Priority, PriorityHandler,
16-
ReceiveOutput,
15+
Http3Parameters, Http3StreamType, NewStreamType, Priority, PriorityHandler, ReceiveOutput,
1716
};
1817
use neqo_common::{
1918
event::Provider as EventProvider, hex, hex_with_len, qdebug, qinfo, qlog::NeqoQlog, qtrace,
20-
Datagram, Decoder, Encoder, MessageType, Role,
19+
Datagram, Decoder, Encoder, Header, MessageType, Role,
2120
};
2221
use neqo_crypto::{agent::CertificateInfo, AuthenticationStatus, ResumptionToken, SecretAgentInfo};
2322
use neqo_qpack::Stats as QpackStats;
@@ -803,7 +802,7 @@ mod tests {
803802
use crate::qpack_encoder_receiver::EncoderRecvStream;
804803
use crate::settings::{HSetting, HSettingType, H3_RESERVED_SETTINGS};
805804
use crate::{Http3Server, Priority, RecvStream};
806-
use neqo_common::{event::Provider, qtrace, Datagram, Decoder, Encoder, Headers};
805+
use neqo_common::{event::Provider, qtrace, Datagram, Decoder, Encoder};
807806
use neqo_crypto::{AllowZeroRtt, AntiReplay, ResumptionToken};
808807
use neqo_qpack::{encoder::QPackEncoder, QpackSettings};
809808
use neqo_transport::tparams::{self, TransportParameter};
@@ -6446,10 +6445,10 @@ mod tests {
64466445
e,
64476446
Http3ClientEvent::HeaderReady {
64486447
stream_id: request_stream_id,
6449-
headers: Headers::new(&[
6448+
headers: vec![
64506449
Header::new(":status", "200"),
64516450
Header::new("content-type", "text/plain")
6452-
]),
6451+
],
64536452
interim: false,
64546453
fin: false,
64556454
}

neqo-http3/src/connection_server.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ use crate::recv_message::{RecvMessage, RecvMessageInfo};
1010
use crate::send_message::SendMessage;
1111
use crate::server_connection_events::{Http3ServerConnEvent, Http3ServerConnEvents};
1212
use crate::{
13-
Error, Header, Http3Parameters, Http3StreamType, NewStreamType, Priority, PriorityHandler,
13+
Error, Http3Parameters, Http3StreamType, NewStreamType, Priority, PriorityHandler,
1414
ReceiveOutput, Res,
1515
};
16-
use neqo_common::{event::Provider, qdebug, qinfo, qtrace, Headers, MessageType, Role};
16+
use neqo_common::{event::Provider, qdebug, qinfo, qtrace, Header, MessageType, Role};
1717
use neqo_transport::{AppError, Connection, ConnectionEvent, StreamId, StreamType};
1818
use std::rc::Rc;
1919
use std::time::Instant;
@@ -75,7 +75,7 @@ impl Http3ServerHandler {
7575
.ok_or(Error::InvalidStreamId)?
7676
.http_stream()
7777
.ok_or(Error::InvalidStreamId)?
78-
.send_headers(Headers::from(headers), conn)?;
78+
.send_headers(headers, conn)?;
7979
self.base_handler.stream_has_pending_data(stream_id);
8080
self.needs_processing = true;
8181
Ok(())

neqo-http3/src/features/extended_connect/session.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use super::{ExtendedConnectEvents, ExtendedConnectType};
1010
use crate::{
1111
CloseType, Error, Http3StreamInfo, HttpRecvStreamEvents, RecvStreamEvents, SendStreamEvents,
1212
};
13-
use neqo_common::{qtrace, Headers, Role};
13+
use neqo_common::{qtrace, Header, Role};
1414
use neqo_transport::StreamId;
1515
use std::cell::RefCell;
1616
use std::collections::BTreeSet;
@@ -148,7 +148,7 @@ impl HttpRecvStreamEvents for Rc<RefCell<ExtendedConnectSession>> {
148148
fn header_ready(
149149
&self,
150150
stream_info: Http3StreamInfo,
151-
headers: Headers,
151+
headers: Vec<Header>,
152152
_interim: bool,
153153
_fin: bool,
154154
) {

0 commit comments

Comments
 (0)