283818 fixed merge of forward parameters

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@585 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2009-07-23 03:28:11 +00:00
parent 5c4fe0615c
commit 74241823dd
5 changed files with 42 additions and 26 deletions

View File

@ -1,6 +1,7 @@
jetty-7.0.0.RC2-SNAPSHOT
+ 283844 Webapp / TLD errors are not clear
+ 283375 improved extensibility of SSL connectors
+ 283818 fixed merge of forward parameters
+ backport jetty-8 annotation parsing to jetty-7
jetty-7.0.0.RC1 15 June 2009

View File

@ -201,6 +201,7 @@ public class Dispatcher implements RequestDispatcher
{
Request baseRequest=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();
Response base_response=baseRequest.getResponse();
response.resetBuffer();
base_response.fwdReset();
request.removeAttribute(__JSP_FILE); // TODO remove when glassfish 1044 is fixed
@ -221,21 +222,26 @@ public class Dispatcher implements RequestDispatcher
_contextHandler.handle(_named,baseRequest, (HttpServletRequest)request, (HttpServletResponse)response);
else
{
String query=_dQuery;
// process any query string from the dispatch URL
String query=_dQuery;
if (query!=null)
{
// extract parameters from dispatch query
MultiMap parameters=new MultiMap();
UrlEncoded.decodeTo(query,parameters,request.getCharacterEncoding());
boolean rewrite_old_query = false;
boolean merge_old_query = false;
// Have we evaluated parameters
if( old_params == null )
{
baseRequest.getParameterNames(); // force parameters to be evaluated
// no - so force parameters to be evaluated
baseRequest.getParameterNames();
old_params = baseRequest.getParameters();
}
// Are there any existing parameters?
if (old_params!=null && old_params.size()>0)
{
// Merge parameters; new parameters of the same name take precedence.
@ -245,24 +251,20 @@ public class Dispatcher implements RequestDispatcher
Map.Entry entry = (Map.Entry)iter.next();
String name=(String)entry.getKey();
// If the names match, we will need to remake the query string
if (parameters.containsKey(name))
{
rewrite_old_query = true;
}
else
{
Object values=entry.getValue();
for (int i=0;i<LazyList.size(values);i++)
{
parameters.add(name, LazyList.get(values, i));
}
}
merge_old_query = true;
// Add the old values to the new parameter map
Object values=entry.getValue();
for (int i=0;i<LazyList.size(values);i++)
parameters.add(name, LazyList.get(values, i));
}
}
if (old_query != null && old_query.length()>0)
{
if ( rewrite_old_query )
if ( merge_old_query )
{
StringBuilder overridden_query_string = new StringBuilder();
MultiMap overridden_old_query = new MultiMap();
@ -333,12 +335,18 @@ public class Dispatcher implements RequestDispatcher
if (baseRequest.getConnection().getResponse().isWriting())
{
try {response.getWriter().close();}
catch(IllegalStateException e) { response.getOutputStream().close(); }
catch(IllegalStateException e)
{
response.getOutputStream().close();
}
}
else
{
try {response.getOutputStream().close();}
catch(IllegalStateException e) { response.getWriter().close(); }
catch(IllegalStateException e)
{
response.getWriter().close();
}
}
}
}

View File

@ -985,6 +985,7 @@ public class Response implements HttpServletResponse
*/
public void reset()
{
resetBuffer();
fwdReset();
_status=200;
_reason=null;

View File

@ -59,15 +59,13 @@ import org.eclipse.jetty.util.log.Log;
* This filter extends {@link UserAgentFilter} and if the the initParameter <code>excludedAgents</code>
* is set to a comma separated list of user agents, then these agents will be excluded from gzip content.
* </p>
*
*
*
*/
public class GzipFilter extends UserAgentFilter
{
protected Set _mimeTypes;
protected int _bufferSize=8192;
protected int _minGzipSize=1;
protected int _minGzipSize=256;
protected Set _excluded;
public void init(FilterConfig filterConfig) throws ServletException
@ -421,10 +419,12 @@ public class GzipFilter extends UserAgentFilter
public void resetBuffer()
{
if (_response.isCommitted())
throw new IllegalStateException("Committed");
_closed=false;
_out=null;
_bOut=null;
if (_gzOut!=null && !_response.isCommitted())
if (_gzOut!=null)
_response.setHeader("Content-Encoding",null);
_gzOut=null;
}
@ -449,6 +449,9 @@ public class GzipFilter extends UserAgentFilter
public void close() throws IOException
{
if (_closed)
return;
if (_request.getAttribute("javax.servlet.include.request_uri")!=null)
flush();
else
@ -561,10 +564,7 @@ public class GzipFilter extends UserAgentFilter
private void checkOut(int length) throws IOException
{
if (_closed)
{
new Throwable().printStackTrace();
throw new IOException("CLOSED");
}
if (_out==null)
{
@ -579,7 +579,7 @@ public class GzipFilter extends UserAgentFilter
{
if (_response.isCommitted() || (_contentLength>=0 && _contentLength<_minGzipSize))
doNotGzip();
else if (length>=(_bOut.size()-_bOut.getCount()))
else if (length>=(_bOut.getBuf().length -_bOut.getCount()))
doGzip();
}
}

View File

@ -27,6 +27,8 @@ import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import org.eclipse.jetty.util.log.Log;
/* ------------------------------------------------------------ */
/** Test Servlet RequestDispatcher.
@ -152,11 +154,15 @@ public class DispatchServlet extends HttpServlet
dispatch.forward(sreq, sres);
try
{
// should be closed
out.println("IOException");
// should not get here
throw new IllegalStateException();
}
catch(IOException e)
{}
{
Log.ignore(e);
}
}
else
{