Intercept an HTTP request at browser end to alter some html content

后端 未结 11 1695
灰色年华
灰色年华 2021-02-06 19:43

I would like to do as follows. What would be the best way? A general answer will also be fine.

I would like to intercept an HTTP request at the client end to alter some

11条回答
  •  无人共我
    2021-02-06 19:59

    You could setup a proxy with HTTPListener. But I would think if you wanted to do it right, you'll need a program that is more low level.

    • Open 2 TCP Ports (80 & 443) and actively listen for incoming connections.
    • Once received
      • Go out and make the request on behalf of the requester
    • Retrieve HTTP Response
    • Inspect and change the HTTP Response (where appropriate)
      • Perhaps modifying headers (where appropriate)
    • Forward on the response to the requester

    I'd start with a simple proxy that just forwards all requests and returns back all responses. Once that is in place you can start inspecting the responses.

    That is a good place to start.

提交回复
热议问题