Skip to content

Commit

Permalink
session-request: add methods for getting origin and user-agent
Browse files Browse the repository at this point in the history
  • Loading branch information
BiagioFesta committed Jun 28, 2023
1 parent ffce537 commit df18ccb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions wtransport-proto/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ impl SessionRequest {
.expect("Session request must contain ':path' field")
}

/// Returns the `origin` field of the request if present.
pub fn origin(&self) -> Option<&str> {
self.0.get("origin")
}

/// Returns the `user-agent` field of the request if present.
pub fn user_agent(&self) -> Option<&str> {
self.0.get("user-agent")
}

/// Gets a field from the request (if present).
pub fn get<K>(&self, key: K) -> Option<&str>
where
Expand Down
10 changes: 10 additions & 0 deletions wtransport/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,16 @@ impl SessionRequest {
self.stream_session.request().path()
}

/// Returns the `origin` field of the request if present.
pub fn origin(&self) -> Option<&str> {
self.stream_session.request().origin()
}

/// Returns the `user-agent` field of the request if present.
pub fn user_agent(&self) -> Option<&str> {
self.stream_session.request().user_agent()
}

/// Returns the whole headers associated with the request.
pub fn headers(&self) -> &Headers {
self.stream_session.request().headers()
Expand Down

0 comments on commit df18ccb

Please sign in to comment.