Skip to content

Commit

Permalink
feat(engineio/ws): clone http request for ws transport (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
Totodore authored Jan 10, 2024
1 parent c17e28a commit f4c12bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
11 changes: 2 additions & 9 deletions engineioxide/src/transport/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,9 @@ pub fn new_req<R: Send + 'static, B, H: EngineIoHandler>(
sid: Option<Sid>,
req: Request<R>,
) -> Result<Response<ResponseBody<B>>, Error> {
let mut parts = Request::builder()
.method(req.method().clone())
.uri(req.uri().clone())
.version(req.version())
.body(())
.unwrap()
.into_parts()
.0;
let (parts, body) = req.into_parts();
let req = Request::from_parts(parts.clone(), body);

parts.headers.extend(req.headers().clone());
let ws_key = parts
.headers
.get("Sec-WebSocket-Key")
Expand Down
5 changes: 1 addition & 4 deletions socketioxide/src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,7 @@ impl<A: Adapter> Socket<A> {

/// Gets the request info made by the client to connect
///
/// Note that the `extensions` field will be empty and will not
/// contain extensions set in the previous http layers for requests initialized with ws transport.
///
/// It is because [`http::Extensions`] is not cloneable and is needed for ws upgrade.
/// It might be used to retrieve the [`http::request::Extensions`]
pub fn req_parts(&self) -> &http::request::Parts {
&self.esocket.req_parts
}
Expand Down

0 comments on commit f4c12bb

Please sign in to comment.