4
votes

I have a wicket application which can be deployed in different environments. One of this environments is a server (lets call it S) behind a https proxy (lets call it P) so the pages on the application are accessed as

https://P:443/path/mountedPackage/Page?params=values

Everything worked fine in wicket 1.4 but with the migration to wicket 1.5, the request URL is changed to

http://P:443/path/mountedPackage/Page?params=values

(https is replaced by http) which leads to a "400 Bad Request" error. I don't know why this happens but it brokes my external links to the application.

NOTE: I had this same problem before when submitting a form and calling the method setResponsePage(Page.class) and I solved it by setting a different RequestTarget and manually adding "https" instead of "http" when corresponds:

on wicket 1.4

component.getRequestCycle().setRequestTarget
      (new RedirectRequestTarget("newURLWithPropperHttps"));

and on wicket 1.5

component.getRequestCycle().scheduleRequestHandlerAfterCurrent(new 
    RedirectRequestHandler("newURLWithPropperHttps"));

but now I am not calling any setResponsePage() or similar it happens when following a normal link from outside.

Any help? It is ok to use same solution as shown, but I don't know where to implement it (I have tried on method get() of the IRequestCycleProvider but that leads me to anohter error)

2
I don't know the answer but it sounds like a bug. - biziclop
Thanks for your comment @biziclop, probably it is, I will try to report that to see what developers say. In the meanwhile I fixed the problem by writting my own IRequestMapper which acts like the default one but on method mapHandler() sets the protocol to https if it has to. final IRequestMapper o=getRootRequestMapper(); setRootRequestMapper(new IRequestMapper() { [...] @Override public Url mapHandler(IRequestHandler r) { Url u=o.mapHandler(r); if (condition) u.setProtocol("https"); return u; } }); - spuas

2 Answers

1
votes

I fixed the problem by writting my own IRequestMapper which acts like the default one but on method mapHandler() sets the protocol to https if it has to.

final IRequestMapper o=getRootRequestMapper();

setRootRequestMapper(new IRequestMapper() {
   [...] 
   @Override
   public Url mapHandler(IRequestHandler r) {
       Url u=o.mapHandler(r);
       if (condition)
          u.setProtocol("https");
       return u;
   }
});