Skip to content

Commit 7e784d8

Browse files
authored
Return warning description only from warning headers (#119)
This commit updates the warning_headers implementation on Response to return a string slice of the warning value from the value of a warning header that is formatted according to RFC 7234.
1 parent 38814ec commit 7e784d8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

elasticsearch/src/http/response.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,12 @@ impl Response {
114114
/// Deprecation headers signal the use of Elasticsearch functionality
115115
/// or features that are deprecated and will be removed in a future release.
116116
pub fn warning_headers(&self) -> impl Iterator<Item = &str> {
117-
self.0
118-
.headers()
119-
.get_all("Warning")
120-
.iter()
121-
.map(|w| w.to_str().unwrap())
117+
self.0.headers().get_all("Warning").iter().map(|w| {
118+
let s = w.to_str().unwrap();
119+
let first_quote = s.find(r#"""#).unwrap();
120+
let last_quote = s.len() - 1;
121+
&s[first_quote + 1..last_quote]
122+
})
122123
}
123124
}
124125

0 commit comments

Comments
 (0)