sockets - Proxy in java - how to modify response data and send it back to browser -


i have created simple proxy forwards requests server , sends response client. however, there additional requirement have implement: modifying response message replace word another. example, have replace occurrences of "hi" "hello" in entity body. after that, send modified response message client.

so far approach this:

1) store response data in byte array first

2) convert byte array string object , read line line until reach entity body

3) there, cut string object 2 parts using substring method

4) parse entity body , replace necessary words new ones

5) piece modified entity body header fields of response message 1 string object

6) convert modified string object byte array , write client

is feasible? or guys know other better approaches?

thank you!


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -