Skip to content

Commit

Permalink
Make TextRequest convert buf to String with lossy
Browse files Browse the repository at this point in the history
  • Loading branch information
2bc4 committed Jan 1, 2024
1 parent e28fd58 commit 0a15049
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ impl TextRequest {
pub fn text(&mut self) -> Result<String> {
perform(&self.handle)?;

let text = str::from_utf8(self.handle.get_ref().writer.as_slice())?.to_owned();
self.handle.get_mut().writer.clear();
let buf = &mut self.handle.get_mut().writer;
let text = String::from_utf8_lossy(buf).to_string();
buf.clear();

Ok(text)
}
Expand Down

0 comments on commit 0a15049

Please sign in to comment.