A HREF rewrite PROXY

Splash Forums Rewrite Users A HREF rewrite PROXY

This topic contains 2 replies, has 2 voices, and was last updated by  anderskristian 1 year, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26593

    anderskristian
    Participant

    I have made a rewrite-war PROXY that uses

    
    perform(Proxy.to("http://otherhost:port/xxx")) 
    

    And it works perfect.
    My observation is that http://otherhost:port sometimes makes ..
    The developers have hardcoded their own host into the links.
    Therefore I need to replace the output stream:

    
    stream "http://otherhost:port/xxx" with "./xxx" 
    

    to bring the
    request back to my proxy server.
    Question 1: Has Direction.isOutbound() anything to do with this ?

    Question 2: Does rewrite contains such filter stream/writers ?

    #26599

    Yes, changing the URLs of a rendered HTML page is possible using outbound rewrites.

    However, this only works, if the URLs are passed through HttpServletResponse.encodeURL(). If the URLs are hardcoded in the HTML page, things are getting more difficult. To modify these URLs, you will have to buffer the response created by the Servlet and postprocess it. There is some support for this in Rewrite. Have a look at the rewrite-transform-* modules. They are used to (for example) minify JS and CSS files. This is basically the same thing as modifying parts of the HTML page. You will have to implement your own Transformer for this. Have a look at the showcase app for transformations for examples:

    https://github.com/ocpsoft/rewrite/tree/master/showcase/transform

    #26603

    anderskristian
    Participant

    Thanks again Christian
    I get it.
    HttpServletResponse.encodeURL() must be used to enable outbound
    I will try Transformer.
    Actually Transformer could find links and parse them through HttpServletResponse.encodeURL() …
    I will take a look
    /Anders

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Comments are closed.