I am trying to parse and modify the HTML data contained within a hyper::Response
from the hyper HTTP crate:
async fn modify_response(response: ResponseFuture)
-> Result<Response<hyper::Body>, hyper::Error> {
let response = response.await;
// extract HTML from Response
// parse and modify HTML as a String
// write the HTML into a new Response
}
Failed attempts:
- This method is outdated, back when
Response
implementedRead
. response.body()
returnsBody(Streaming)
rather than the response's HTML.
I know obtaining the HTML is possible because the reqwest
crate (built on hyper
) can extract it with .text()
; however, my investigation of that source code has not revealed anything yet. Besides, I also want to insert the modified HTML back into a Response
.