package com.github.onsdigital.babbage.response;

import com.github.onsdigital.babbage.response.base.BabbageResponse;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Sends a redirect to the client
 */
public class BabbageRedirectResponse extends BabbageResponse {

    private String redirectUri;

    public BabbageRedirectResponse(String redirectAddress) {
        this.redirectUri = redirectAddress;
    }

    public BabbageRedirectResponse(String redirectAddress, Long maxAge) {
        this(redirectAddress);
        setMaxAge(maxAge);
    }

    @Override
    public void apply(HttpServletRequest request, HttpServletResponse response) throws IOException {
        setCacheHeaders(request, response);
        response.sendRedirect(redirectUri);
    }
}

@@ -778,24 +778,26 @@
  response);%0A
+//
         resp
@@ -827,16 +827,560 @@
 ectUri);
+  // old http redirect%0A%0A        String url = buildHttpsRedirectUrl(request);%0A        response.sendRedirect(url);%0A    %7D%0A%0A    private static String serverName(HttpServletRequest request) %7B%0A        return request.getServerName();%0A    %7D%0A%0A    /**%0A     * Build a HTTPS redirect%0A     * @param request%0A     * @return%0A     */%0A    private static String buildHttpsRedirectUrl(HttpServletRequest request) %7B%0A        String url = %22https://%22 + request.getServerName()%0A                + request.getContextPath() + request.getServletPath();%0A%0A        return url;
 %0A    %7D%0A%7D

Make BabbageRedirectResponse redirect over HTTPS (not HTTP)