Skip to content
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

Expose zero-copy-ish headers on ClientRequest #35

Merged
merged 18 commits into from
Jun 11, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/handshake/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ pub struct Server<'a, T> {
buffer: BytesMut
}

/// Owned value of the `Sec-WebSocket-Key` header.
pub type WebSocketKey = ArrayVec<u8, 28>;

impl<'a, T: AsyncRead + AsyncWrite + Unpin> Server<'a, T> {
/// Create a new server handshake.
pub fn new(socket: T) -> Self {
Expand Down Expand Up @@ -164,7 +161,7 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Server<'a, T> {
let headers = RequestHeaders { host, origin };

let ws_key = with_first_header(&request.headers, "Sec-WebSocket-Key", |k| {
let mut key = ArrayVec::new();
let mut key = WebSocketKey::new();

match key.try_extend_from_slice(k) {
Ok(()) => Ok(key),
Expand Down Expand Up @@ -235,6 +232,9 @@ impl<'a, T: AsyncRead + AsyncWrite + Unpin> Server<'a, T> {
}
}

/// Owned value of the `Sec-WebSocket-Key` header.
pub type WebSocketKey = ArrayVec<u8, 28>;

/// Handshake request received from the client.
#[derive(Debug)]
pub struct ClientRequest<'a> {
Expand Down