Skip to content

Commit

Permalink
fix: check user_agent for null
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanitskiy committed Sep 1, 2023
1 parent 840d789 commit 0ca0bc9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/http/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,12 @@ impl Request {
/// Client HTTP [User-Agent].
///
/// [User-Agent]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent
pub fn user_agent(&self) -> &NgxStr {
unsafe { NgxStr::from_ngx_str((*self.0.headers_in.user_agent).value) }
pub fn user_agent(&self) -> Option<&NgxStr> {
if !self.0.headers_in.user_agent.is_null() {
unsafe { Some(NgxStr::from_ngx_str((*self.0.headers_in.user_agent).value)) }
} else {
None
}
}

/// Set HTTP status of response.
Expand Down

0 comments on commit 0ca0bc9

Please sign in to comment.