HttpRewriteWrappedResponse cannot handle Transformer

Splash Forums Rewrite Users HttpRewriteWrappedResponse cannot handle Transformer

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  Lincoln Baxter III 1 year, 7 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26697

    anderskristian
    Participant

    I am trying to pass the response from an incomming stream through a Transforer (to convert href’s)
    This fails because the response comes from a “Proxy.to”

    I have a suggestion to improve the IllegalStateException 10 grams.
    I have added the request.getRequestURI() to a formatted string.

    
    HttpRewriteWrappedResponse
    
       @Override
       public void addContentInterceptor(ResponseContentInterceptor stage) throws IllegalStateException
       {
          if (areStreamsLocked())
          {
             throw new IllegalStateException(
                      String.format(
                          "Cannot add output buffers to Response %s once request processing has been passed to the application."
                          ,this.request.getRequestURI()));
          }
          this.responseContentInterceptors.add(stage);
       }
    
    

    My code is: (dmi is just a sample, I have nothing to do with that company)

    
       .addRule().when(Direction.isInbound().and(Path.matches("/module/dmi/")))
       .perform(Proxy.to("http://www.dmi.com:80/").and(Transform.with(new HrefTransformer())))
    

    Currently I understand that Transform cannot be after Proxy.to ..

    #26698

    Hi! Thank you for your suggestion. Would you mind sending a pull request for that? https://github.com/ocpsoft/rewrite/blob/master/impl-servlet/src/main/java/org/ocpsoft/rewrite/servlet/impl/HttpRewriteWrappedResponse.java

    Also, have you tried adding the transformer before performing the proxy operation?

       .addRule().when(Direction.isInbound().and(Path.matches("/module/dmi/")))
       .perform(Transform.with(new HrefTransformer()).and(Proxy.to("http://www.dmi.com:80/")))

    I believe this might resolve the error entirely.

    #26704

    anderskristian
    Participant

    Hi Lincoln
    I have made a pull request with the change.
    I made in “master” branch the sender is “anderskristian”
    it is a small thing, but it was nice to try this pull thing out…
    Maybe I get the HrefTransformer working… so I can make pull request for that one…

    Yes swapping the Transform and Proxy did work !!!
    I made an internal test with own “sub-web” that worked fine 🙂

    But http://www.dmi.com does not work, seems to send compressed….
    The StringTransformer cannot handle dmi.com as well.

    Maybe I will ignore that problem, I am not going to proxy to external pages anyway. But understanding the problem could be nice.

    #26711

    Yeah. I’m not really sure that you want to be using the Transformer API if you have any binary content. It was really intended for rendering documents from markdown, or changing text formats. The ResponseContentInterceptor or ResponseStreamInterceptor might be more what you are looking for?

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

You must be logged in to reply to this topic.

Comments are closed.