On Wednesday, March 14, 2012 10:09:51 AM Aki Yoshida wrote: > Hi Dan, > I thought it is strange that the setHeadFalse method is setting the > head to true. > Maybe there is a typo there?
Oops. yea. Thanks for spotting that. Was definitely having an "I hate Jetty" kind of day. :-( Dan > regards, aki > > 2012/3/13 <[email protected]>: > > Author: dkulp > > Date: Tue Mar 13 20:34:14 2012 > > New Revision: 1300342 > > > > URL: http://svn.apache.org/viewvc?rev=1300342&view=rev > > Log: > > [CXF-4175] more fixes for Jetty compatibility > > > > Modified: > > > > cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transp > > ort/http_jetty/JettyHTTPDestination.java > > > > Modified: > > cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transpo > > rt/http_jetty/JettyHTTPDestination.java URL: > > http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/mai > > n/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev > > =1300342&r1=1300341&r2=1300342&view=diff > > ======================================================================= > > ======= --- > > cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transpo > > rt/http_jetty/JettyHTTPDestination.java (original) +++ > > cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transpo > > rt/http_jetty/JettyHTTPDestination.java Tue Mar 13 20:34:14 2012 @@ > > -53,10 +53,10 @@ import org.apache.cxf.transport.https.Ce > > import org.apache.cxf.transports.http.QueryHandler; > > import org.apache.cxf.transports.http.QueryHandlerRegistry; > > import org.apache.cxf.transports.http.StemMatchingQueryHandler; > > +import org.eclipse.jetty.http.Generator; > > import org.eclipse.jetty.io.AbstractConnection; > > -import org.eclipse.jetty.server.AsyncHttpConnection; > > -import org.eclipse.jetty.server.BlockingHttpConnection; > > import org.eclipse.jetty.server.Request; > > +import org.springframework.util.ClassUtils; > > > > public class JettyHTTPDestination extends AbstractHTTPDestination { > > > > @@ -223,6 +223,15 @@ public class JettyHTTPDestination extend > > } > > } > > > > + private void setHeadFalse(AbstractConnection con) { > > + try { > > + Generator gen = > > (Generator)con.getClass().getMethod("getGenerator").invoke(con); + > > gen.setHead(true); > > + } catch (Exception ex) { > > + //ignore - can continue > > + } > > + } > > + > > protected void doService(ServletContext context, > > HttpServletRequest req, > > HttpServletResponse resp) throws > > IOException { @@ -237,11 +246,7 @@ public class JettyHTTPDestination > > extend > > //sent, a _head flag is never reset > > AbstractConnection c = getConnectionForRequest(baseRequest); > > if (c != null) { > > - if (c instanceof AsyncHttpConnection) { > > - > > ((AsyncHttpConnection)c).getGenerator().setHead(false); - > > } else if (c instanceof BlockingHttpConnection) { - > > ((BlockingHttpConnection)c).getGenerator().setHead(false); - > > } > > + setHeadFalse(c); > > } > > } > > if (getServer().isSetRedirectURL()) { > > @@ -381,8 +386,23 @@ public class JettyHTTPDestination extend > > } > > > > private AbstractConnection getCurrentConnection() { > > - Class<?> cls = AsyncHttpConnection.class.getSuperclass(); > > // AbstractHttpConnection on Jetty 7.6, HttpConnection on Jetty > > <=7.5 + Class<?> cls = null; > > + try { > > + cls = > > ClassUtils.forName("org.eclipse.jetty.server.AbstractHttpConnection", + > > > > AbstractConnection.class.getClassLoader()); + } catch (Exception > > e) { > > + //ignore > > + } > > + if (cls == null) { > > + try { > > + cls = > > ClassUtils.forName("org.eclipse.jetty.server.HttpConnection", + > > > > AbstractConnection.class.getClassLoader()); + } catch > > (Exception e) { > > + //ignore > > + } > > + } > > + > > try { > > return (AbstractConnection)ReflectionUtil > > > > .setAccessible(cls.getMethod("getCurrentConnection")).invoke(null); @@ > > -393,10 +413,11 @@ public class JettyHTTPDestination extend > > } > > private Request getCurrentRequest() { > > AbstractConnection con = getCurrentConnection(); > > - if (con instanceof AsyncHttpConnection) { > > - return ((AsyncHttpConnection)con).getRequest(); > > - } else if (con instanceof BlockingHttpConnection) { > > - return ((BlockingHttpConnection)con).getRequest(); > > + try { > > + return (Request)ReflectionUtil > > + > > .setAccessible(con.getClass().getMethod("getRequest")).invoke(con); + > > } catch (Exception e) { > > + //ignore > > } > > return null; > > } -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
