0

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 implemented Read.
  • response.body() returns Body(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.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
springworks00
  • 104
  • 15
  • It looks like your question might be answered by the answers of [How do I read the entire body of a Tokio-based Hyper request?](https://stackoverflow.com/q/43419974/155423). If not, please **[edit]** your question to explain the differences. Otherwise, we can mark this question as already answered. – Shepmaster Aug 05 '20 at 02:02
  • 1
    Yes, it does. Thank you! – springworks00 Aug 05 '20 at 05:07

0 Answers0