cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r570241 - in /incubator/cxf/trunk/rt: core/src/main/java/org/apache/cxf/interceptor/ core/src/main/java/org/apache/cxf/transport/http/ transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ transports/http-jetty/src/test/j...
Date Mon, 27 Aug 2007 21:01:51 GMT
Author: dkulp
Date: Mon Aug 27 14:01:50 2007
New Revision: 570241

URL: http://svn.apache.org/viewvc?rev=570241&view=rev
Log:
[CXF-687] Fix issue of multiple Content-Type headers on wire when using WS-Policy
* Fix problem of JettyHTTPDestination not setting encoding (so StaxIn always assume UTF-8)
* Fix problem of HTTP logging not finding messages (transport.http package exists in two jars,
not good)
* Add logging of encoding and protocol headers to LoggingInInterceptor
* Add more logging in HTTPConduit


Added:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/QueryMessages.properties
      - copied unchanged from r570145, incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/Messages.properties
Removed:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/Messages.properties
Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
    incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
    incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=570241&r1=570240&r2=570241&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
Mon Aug 27 14:01:50 2007
@@ -43,30 +43,39 @@
     }
 
     public void handleMessage(Message message) throws Fault {
-        InputStream is = message.getContent(InputStream.class);
-
-        if (is == null) {
-            return;
-        }
 
         if (LOG.isLoggable(Level.INFO)) {
-            CachedOutputStream bos = new CachedOutputStream();
-            try {
-                IOUtils.copy(is, bos);
-
-                is.close();
-                bos.close();
+            StringBuffer buffer = new StringBuffer("Inbound Message\n" 
+                                                   + "--------------------------------------");
+            
+            String encoding = (String)message.get(Message.ENCODING);
+            if (encoding != null) {
+                buffer.append("\nEncoding: " + encoding);
+            }
+            Object headers = message.get(Message.PROTOCOL_HEADERS);
+            if (headers != null) {
+                buffer.append("\nHeaders: " + headers);
+            }
+            
+            InputStream is = message.getContent(InputStream.class);
+            if (is != null) {
+                CachedOutputStream bos = new CachedOutputStream();
+                try {
+                    IOUtils.copy(is, bos);
 
-                LOG.info("Inbound Message\n" 
-                         + "--------------------------------------\n"
-                         + bos.getOut().toString()
-                         + "\n--------------------------------------");
-                
-                message.setContent(InputStream.class, bos.getInputStream());
+                    is.close();
+                    bos.close();
 
-            } catch (IOException e) {
-                throw new Fault(e);
+                    buffer.append("\nMessage:\n");
+                    buffer.append(bos.getOut().toString());
+                    
+                    message.setContent(InputStream.class, bos.getInputStream());
+                } catch (IOException e) {
+                    throw new Fault(e);
+                }
             }
+            buffer.append("\n--------------------------------------");
+            LOG.info(buffer.toString());
         }
     }
 

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties?rev=570241&r1=570240&r2=570241&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
Mon Aug 27 14:01:50 2007
@@ -18,7 +18,7 @@
 #    under the License.
 #
 #
-STREAM_CREATE_EXC = Could not create XMLStreamReader.
+STREAM_CREATE_EXC = Could not create XMLStreamReader(encoding {0}).
 STAX_READ_EXC = Could not read from XMLStreamReader.
 STAX_WRITE_EXC = Could not write to XMLStreamWriter.
 NO_OPERATION_ELEMENT=There must be an operation element.

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java?rev=570241&r1=570240&r2=570241&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/StaxInInterceptor.java
Mon Aug 27 14:01:50 2007
@@ -22,7 +22,6 @@
 import java.io.InputStream;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
 import javax.xml.stream.XMLInputFactory;
@@ -30,7 +29,7 @@
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -40,8 +39,7 @@
  * Creates an XMLStreamReader from the InputStream on the Message.
  */
 public class StaxInInterceptor extends AbstractPhaseInterceptor<Message> {
-    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(StaxInInterceptor.class);
-    private static final Logger LOG = Logger.getLogger(StaxInInterceptor.class.getName());
   
+    private static final Logger LOG = LogUtils.getL7dLogger(StaxInInterceptor.class);   

 
     private static Map<Object, XMLInputFactory> factories = new HashMap<Object,
XMLInputFactory>();
 
@@ -66,7 +64,10 @@
         try {
             reader = getXMLInputFactory(message).createXMLStreamReader(is, encoding);
         } catch (XMLStreamException e) {
-            throw new Fault(new org.apache.cxf.common.i18n.Message("STREAM_CREATE_EXC", BUNDLE),
e);
+            throw new Fault(new org.apache.cxf.common.i18n.Message("STREAM_CREATE_EXC",
+                                                                   LOG,
+                                                                   encoding),
+                            e);
         }
 
         message.setContent(XMLStreamReader.class, reader);
@@ -91,7 +92,7 @@
                 } else {
                     throw new Fault(
                                     new org.apache.cxf.common.i18n.Message("INVALID_INPUT_FACTORY",

-                                                                           BUNDLE, o));
+                                                                           LOG, o));
                 }
 
                 try {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java?rev=570241&r1=570240&r2=570241&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/http/WSDLQueryHandler.java
Mon Aug 27 14:01:50 2007
@@ -65,7 +65,7 @@
 
 public class WSDLQueryHandler implements StemMatchingQueryHandler {
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(WSDLQueryHandler.class);
-    private static final Logger LOG = LogUtils.getL7dLogger(WSDLQueryHandler.class);
+    private static final Logger LOG = LogUtils.getL7dLogger(WSDLQueryHandler.class, "QueryMessages");
     private Bus bus;
 
     public WSDLQueryHandler(Bus b) {

Modified: incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=570241&r1=570240&r2=570241&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
Mon Aug 27 14:01:50 2007
@@ -239,7 +239,7 @@
             inMessage.put(HTTP_RESPONSE, resp);
             inMessage.put(Message.HTTP_REQUEST_METHOD, req.getMethod());
             inMessage.put(Message.PATH_INFO, req.getContextPath() + req.getPathInfo());
-            
+            inMessage.put(Message.ENCODING, req.getCharacterEncoding());
             inMessage.put(Message.QUERY_STRING, req.getQueryString());
             inMessage.put(Message.CONTENT_TYPE, req.getContentType());
             if (!StringUtils.isEmpty(endpointInfo.getAddress())) {

Modified: incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java?rev=570241&r1=570240&r2=570241&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
(original)
+++ incubator/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
Mon Aug 27 14:01:50 2007
@@ -580,6 +580,7 @@
                 EasyMock.expect(request.getInputStream()).andReturn(is);
                 EasyMock.expect(request.getContextPath()).andReturn("/bar");
                 EasyMock.expect(request.getPathInfo()).andReturn("/foo");
+                EasyMock.expect(request.getCharacterEncoding()).andReturn("UTF-8");
                 EasyMock.expect(request.getQueryString()).andReturn(query);            
                 EasyMock.expect(request.getContentType()).andReturn("text/xml charset=utf8");
                 
@@ -671,6 +672,8 @@
         EasyMock.expectLastCall().andReturn(new StringBuffer("http://localhost/bar/foo")).times(2);
         request.getPathInfo();
         EasyMock.expectLastCall().andReturn("/bar/foo");
+        request.getCharacterEncoding();
+        EasyMock.expectLastCall().andReturn("UTF-8");
         request.getQueryString();
         EasyMock.expectLastCall().andReturn("wsdl");       
         response.setContentType("text/xml");

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=570241&r1=570240&r2=570241&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Mon Aug 27 14:01:50 2007
@@ -139,6 +139,10 @@
                 }
             }
         }
+        
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.log(Level.FINE, "Request Headers: " + requestHeaders.toString());
+        }
            
     }
     

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=570241&r1=570240&r2=570241&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Mon Aug 27 14:01:50 2007
@@ -814,15 +814,12 @@
             if (enc != null && ct.indexOf("charset=") == -1) {
                 ct = ct + "; charset=" + enc;
             }
-            connection.setRequestProperty(
-                    HttpHeaderHelper.CONTENT_TYPE, ct);
         } else if (enc != null) {
-            connection.setRequestProperty(
-                    HttpHeaderHelper.CONTENT_TYPE, "text/xml; charset=" + enc);
+            ct = "text/xml; charset=" + enc;
         } else {
-            connection.setRequestProperty(
-                    HttpHeaderHelper.CONTENT_TYPE, "text/xml");
+            ct = "text/xml";
         }
+        connection.setRequestProperty(HttpHeaderHelper.CONTENT_TYPE, ct);
         
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Sending "
@@ -830,7 +827,8 @@
                 + " Message with Headers to " 
                            + connection.getURL()
                 + " Conduit :"
-                + getConduitName());
+                + getConduitName()
+                + "\nContent-Type: " + ct + "\n");
             logProtocolHeaders(Level.FINE, message);
         }
         
@@ -1125,8 +1123,7 @@
                 Arrays.asList(new String[] {policy.getAcceptLanguage()}));
         }
         if (policy.isSetContentType()) {
-            headers.put(HttpHeaderHelper.CONTENT_TYPE,
-                Arrays.asList(new String[] {policy.getContentType()}));
+            message.put(Message.CONTENT_TYPE, policy.getContentType());
         }
         if (policy.isSetCookie()) {
             headers.put("Cookie",

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java?rev=570241&r1=570240&r2=570241&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java
Mon Aug 27 14:01:50 2007
@@ -380,7 +380,6 @@
         } else if (p2.isSetAutoRedirect()) {
             p.setAutoRedirect(p2.isAutoRedirect());
         } 
-        p.setAutoRedirect(p1.isAutoRedirect());
         p.setBrowserType(combine(p1.getBrowserType(), p2.getBrowserType()));
         if (p1.isSetCacheControl()) {
             p.setCacheControl(p1.getCacheControl());
@@ -392,7 +391,11 @@
         } else if (p2.isSetConnection()) {
             p.setConnection(p2.getConnection());
         }        
-        p.setContentType(p1.getContentType());
+        if (p1.isSetContentType()) {
+            p.setContentType(p1.getContentType());
+        } else if (p2.isSetContentType()) {
+            p.setContentType(p2.getContentType());            
+        }
         p.setCookie(combine(p1.getCookie(), p2.getCookie()));
         p.setDecoupledEndpoint(combine(p1.getDecoupledEndpoint(), p2.getDecoupledEndpoint()));
         p.setHost(combine(p1.getHost(), p2.getHost()));



Mime
View raw message