Skip to content

Commit

Permalink
[FIXED JENKINS-15437]
Browse files Browse the repository at this point in the history
The exception handler ended up adding almost all the headers again,
resulting in a lot of duplicate headers.

Most critically, stapler was adding "Content-Encoding" header twice,
breaking browsers.

(cherry picked from commit d357554)

Conflicts:
	changelog.html
	core/pom.xml
  • Loading branch information
kohsuke authored and olivergondza committed Sep 23, 2013
1 parent e387005 commit af59db0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
22 changes: 3 additions & 19 deletions core/src/main/java/hudson/security/AccessDeniedHandlerImpl.java
Expand Up @@ -27,6 +27,7 @@
import org.acegisecurity.AccessDeniedException;
import org.acegisecurity.ui.AccessDeniedHandler;
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.WebApp;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
Expand All @@ -52,25 +53,8 @@ public void handle(ServletRequest request, ServletResponse response, AccessDenie

rsp.setStatus(HttpServletResponse.SC_FORBIDDEN);
req.setAttribute("exception",accessDeniedException);
Stapler stapler = new Stapler();
stapler.init(new ServletConfig() {
public String getServletName() {
return "Stapler";
}

public ServletContext getServletContext() {
return Jenkins.getInstance().servletContext;
}

public String getInitParameter(String name) {
return null;
}

public Enumeration getInitParameterNames() {
return new Vector().elements();
}
});

stapler.invoke(req,rsp, Jenkins.getInstance(),"/accessDenied");
WebApp.get(Jenkins.getInstance().servletContext).getSomeStapler()
.invoke(req,rsp, Jenkins.getInstance(), "/accessDenied");
}
}
20 changes: 10 additions & 10 deletions core/src/main/resources/lib/layout/layout.jelly
Expand Up @@ -53,9 +53,9 @@ THE SOFTWARE.
(The permission will be checked against the "it" object.)
</st:attribute>
</st:documentation>
<st:header name="Expires" value="0" />
<st:header name="Cache-Control" value="no-cache,must-revalidate" />
<st:header name="X-Hudson-Theme" value="default" />
<st:setHeader name="Expires" value="0" />
<st:setHeader name="Cache-Control" value="no-cache,must-revalidate" />
<st:setHeader name="X-Hudson-Theme" value="default" />
<st:contentType value="text/html;charset=UTF-8" />

<j:new var="h" className="hudson.Functions" /><!-- instead of JSP functions -->
Expand All @@ -71,15 +71,15 @@ ${h.initPageVariables(context)}
<j:set var="_" value="${h.configureAutoRefresh(request, response, attrs.norefresh!=null)}"/>

<j:if test="${request.servletPath=='/' || request.servletPath==''}">
<st:header name="X-Hudson" value="1.395"/>
<st:header name="X-Jenkins" value="${servletContext.getAttribute('version')}"/>
<st:header name="X-Jenkins-Session" value="${app.SESSION_HASH}"/>
<st:setHeader name="X-Hudson" value="1.395"/>
<st:setHeader name="X-Jenkins" value="${servletContext.getAttribute('version')}"/>
<st:setHeader name="X-Jenkins-Session" value="${app.SESSION_HASH}"/>
<j:if test="${app.tcpSlaveAgentListener!=null}">
<!-- advertise the CLI TCP port -->
<st:header name="X-Hudson-CLI-Port" value="${app.tcpSlaveAgentListener.port}"/>
<st:header name="X-Jenkins-CLI-Port" value="${app.tcpSlaveAgentListener.port}"/>
<st:header name="X-Jenkins-CLI2-Port" value="${app.tcpSlaveAgentListener.port}"/>
<st:header name="X-Jenkins-CLI-Host" value="${app.tcpSlaveAgentListener.CLI_HOST_NAME}"/>
<st:setHeader name="X-Hudson-CLI-Port" value="${app.tcpSlaveAgentListener.port}"/>
<st:setHeader name="X-Jenkins-CLI-Port" value="${app.tcpSlaveAgentListener.port}"/>
<st:setHeader name="X-Jenkins-CLI2-Port" value="${app.tcpSlaveAgentListener.port}"/>
<st:setHeader name="X-Jenkins-CLI-Host" value="${app.tcpSlaveAgentListener.CLI_HOST_NAME}"/>
</j:if>
<j:forEach var="pd" items="${h.pageDecorators}">
<st:include it="${pd}" page="httpHeaders.jelly" optional="true"/>
Expand Down

0 comments on commit af59db0

Please sign in to comment.