Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323435

Summary: MovedContextHandler uses 302 (moved temporarily) when _permanent is true
Product: [RT] Jetty Reporter: Boris Hamanov <bsh666>
Component: serverAssignee: Greg Wilkins <gregw>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: jetty-inbox
Version: unspecified   
Target Milestone: 7.1.x   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description Boris Hamanov CLA 2010-08-23 15:49:06 EDT
Build Identifier: jetty-7.1.6.v20100715

I confirmed that when seeing the headers from my server. This problem is critical as Google and some of the other search engines threat 302 differently from 301 and that will seriously affect a site ranking by splitting link value between the urls that you want to forward to one another. For example when redirecting non www version of the domain site to www.
 
I looked at the source, but I am unable to fix that myself. It seems like 
response.setStatus(_permanent?HttpServletResponse.SC_MOVED_PERMANENTLY:HttpServletResponse.SC_FOUND); does not set status, probably because setStatus in org.eclipse.jetty.server.Response cannot set it properly after sendRedirect is passed. Maybe it has something to do with this line: if (!_connection.isIncluding()) -> set the status. This is all the help I can give. Please, fix this soon, many people have problems with it, without even knowing! Thanks!

This is my context xml:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<Configure class="org.eclipse.jetty.server.handler.MovedContextHandler">
  <Set name="contextPath">/</Set>
  <Set name="newContextURL">http://www.somedomain.com</Set>
  <Set name="permanent">true</Set>
  <Set name="discardPathInfo">false</Set>
  <Set name="discardQuery">false</Set>

  <Set name="virtualHosts">
    <Array type="String">
          <Item>somedomain.com</Item>
          <Item>111.111.111.111</Item>
    </Array>
  </Set>


</Configure>


Reproducible: Always

Steps to Reproduce:
1. use MovedContextHandler in XML conf context (<Set name="permanent">true</Set>)
2. visit the source redirect url and get redirected
3. check the headers that server returned - they are 302, not 301
Comment 1 Greg Wilkins CLA 2010-08-24 04:21:13 EDT
the sendRedirect line should have been deleted.

fixed in r2222
Comment 2 Boris Hamanov CLA 2010-08-24 05:24:40 EDT
Would that fix be in Jetty 7.2.2... ?? Or some CVN build?