You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/06/09 21:54:54 UTC
svn commit: r783117 - in /cxf/branches/2.1.x-fixes: ./
common/common/src/main/java/org/apache/cxf/helpers/
common/common/src/test/java/org/apache/cxf/helpers/
rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/
rt/javascript/src/test/jav...
Author: dkulp
Date: Tue Jun 9 19:54:53 2009
New Revision: 783117
URL: http://svn.apache.org/viewvc?rev=783117&view=rev
Log:
Merged revisions 783099 via svnmerge from
https://svn.apache.org/repos/asf/cxf/branches/2.2.x-fixes
................
r783099 | dkulp | 2009-06-09 15:25:09 -0400 (Tue, 09 Jun 2009) | 10 lines
Merged revisions 783097 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r783097 | dkulp | 2009-06-09 15:11:25 -0400 (Tue, 09 Jun 2009) | 2 lines
[CXF-2274] Make sure we default to ISO-8859-1 if charset is not
specified for http
........
................
Modified:
cxf/branches/2.1.x-fixes/ (props changed)
cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
cxf/branches/2.1.x-fixes/common/common/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java
cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java
cxf/branches/2.1.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java
cxf/branches/2.1.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
cxf/branches/2.1.x-fixes/rt/javascript/src/test/resources/XMLHttpRequestTestBeans.xml
cxf/branches/2.1.x-fixes/rt/javascript/src/test/resources/org/apache/cxf/javascript/XMLHttpRequestTests.js
cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java
Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jun 9 19:54:53 2009
@@ -1,2 +1,2 @@
-/cxf/branches/2.2.x-fixes:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979,775423,776024-776025,776218,776429,776459,777189,777224,777243,777481,777505,777572,777580,780033,780184,780213,780421,780664,780800,780902,780911,781497,781841,782733,782735-782736
-/cxf/trunk:782181,782728-782730
+/cxf/branches/2.2.x-fixes:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979,775423,776024-776025,776218,776429,776459,777189,777224,777243,777481,777505,777572,777580,780033,780184,780213,780421,780664,780800,780902,780911,781497,781841,782733,782735-782736,783099
+/cxf/trunk:782181,782728-782730,783097
Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java?rev=783117&r1=783116&r2=783117&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java (original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java Tue Jun 9 19:54:53 2009
@@ -39,8 +39,7 @@
public static final String CONNECTION = "Connection";
public static final String CLOSE = "close";
public static final String AUTHORIZATION = "Authorization";
- private static final Charset UTF8 = Charset.forName("utf-8");
-
+ private static final String ISO88591 = Charset.forName("ISO-8859-1").name();
private static Map<String, String> internalHeaders = new HashMap<String, String>();
private static Map<String, String> encodings = new ConcurrentHashMap<String, String>();
@@ -91,12 +90,15 @@
}
return null;
}
+ public static String mapCharset(String enc) {
+ return mapCharset(enc, ISO88591);
+ }
//helper to map the charsets that various things send in the http Content-Type header
//into something that is actually supported by Java and the Stax parsers and such.
- public static String mapCharset(String enc) {
+ public static String mapCharset(String enc, String deflt) {
if (enc == null) {
- return UTF8.name();
+ return deflt;
}
//older versions of tomcat don't properly parse ContentType headers with stuff
//after charset="UTF-8"
@@ -109,7 +111,7 @@
enc = enc.replace("\"", "").trim();
enc = enc.replace("'", "");
if ("".equals(enc)) {
- return UTF8.name();
+ return deflt;
}
String newenc = encodings.get(enc);
if (newenc == null) {
Modified: cxf/branches/2.1.x-fixes/common/common/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java?rev=783117&r1=783116&r2=783117&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java (original)
+++ cxf/branches/2.1.x-fixes/common/common/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java Tue Jun 9 19:54:53 2009
@@ -33,7 +33,7 @@
String cs = HttpHeaderHelper.mapCharset("utf-8");
assertEquals(Charset.forName("utf-8").name(), cs);
cs = HttpHeaderHelper.mapCharset(null);
- assertEquals("UTF-8", cs);
+ assertEquals("ISO-8859-1", cs);
cs = HttpHeaderHelper.mapCharset("\"utf-8\"");
assertEquals(Charset.forName("utf-8").name(), cs);
cs = HttpHeaderHelper.mapCharset("'utf-8'");
Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java?rev=783117&r1=783116&r2=783117&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/DataHandlerType.java Tue Jun 9 19:54:53 2009
@@ -70,7 +70,7 @@
charset = charset.substring(0, charset.indexOf(";"));
}
}
- String normalizedEncoding = HttpHeaderHelper.mapCharset(charset);
+ String normalizedEncoding = HttpHeaderHelper.mapCharset(charset, "UTF-8");
try {
String stringData = new String(bareBytes, normalizedEncoding);
return new DataHandler(stringData, contentType);
Modified: cxf/branches/2.1.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java?rev=783117&r1=783116&r2=783117&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/JsHttpRequestTest.java Tue Jun 9 19:54:53 2009
@@ -58,7 +58,8 @@
properties.setProperty("staticResourceURL", getStaticResourceURL());
cfg.setProperties(properties);
// now actually do the replacement
- cfg.postProcessBeanFactory(applicationContext.getBeanFactory());
+ cfg.postProcessBeanFactory(applicationContext.getBeanFactory());
+
}
@Override
@@ -85,7 +86,7 @@
testUtilities.rhinoCallInContext("testStateNotificationSync");
Notifier notifier = testUtilities.rhinoCallConvert("testAsyncHttpFetch1", Notifier.class);
testUtilities.rhinoCallInContext("testAsyncHttpFetch2");
- boolean notified = notifier.waitForJavascript(100);
+ boolean notified = notifier.waitForJavascript(10000);
assertTrue(notified);
assertEquals("HEADERS_RECEIVED", Boolean.TRUE,
testUtilities.rhinoEvaluateConvert("asyncGotHeadersReceived", Boolean.class));
@@ -126,7 +127,7 @@
XPath echoStringPath = new DOMXPath("//t:responseType/text()");
echoStringPath.addNamespace("t", "http://apache.org/hello_world_xml_http/wrapped/types");
String nodeText = echoStringPath.stringValueOf(echoStringPath.selectSingleNode(doc));
- assertEquals(nodeText, "Hello \u05e9\u05dc\u05d5\u05dd");
+ assertEquals("Hello \u05e9\u05dc\u05d5\u05dd", nodeText);
}
public String getStaticResourceURL() throws Exception {
Modified: cxf/branches/2.1.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java?rev=783117&r1=783116&r2=783117&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java Tue Jun 9 19:54:53 2009
@@ -54,6 +54,7 @@
import org.xml.sax.SAXException;
import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.HttpHeaderHelper;
import org.jdom.input.DOMBuilder;
import org.jdom.output.XMLOutputter;
import org.mozilla.javascript.Context;
@@ -362,12 +363,25 @@
baos.write(buffer, 0, read);
}
is.close();
- // convert bytes to text.
- String contentEncoding = connection.getContentEncoding();
+
+ // For a one-way message or whatever, there may not be a content type.
+ // throw away any encoding modifier.
+ String contentType = "";
+ String connectionContentType = connection.getContentType();
+ String contentEncoding = null;
+ if (connectionContentType != null) {
+ contentEncoding = HttpHeaderHelper
+ .mapCharset(HttpHeaderHelper.findCharset(connectionContentType));
+ contentType = connectionContentType.split(";")[0];
+ }
if (contentEncoding == null || contentEncoding.length() == 0) {
- contentEncoding = "utf-8";
+ contentEncoding = "iso-8859-1";
}
+ /* We need all the text in a string, independent of the
+ * XML parse.
+ */
+
Charset contentCharset = Charset.forName(contentEncoding);
byte[] contentBytes = baos.toByteArray();
CharBuffer contentChars =
@@ -375,12 +389,6 @@
responseText = contentChars.toString();
LOG.fine(responseText);
- // For a one-way message or whatever, there may not be a content type.
- // throw away any encoding modifier.
- String contentType = "";
- if (connection.getContentType() != null) {
- contentType = connection.getContentType().split(";")[0];
- }
if ("text/xml".equals(contentType)
|| "application/xml".equals(contentType)
Modified: cxf/branches/2.1.x-fixes/rt/javascript/src/test/resources/XMLHttpRequestTestBeans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/javascript/src/test/resources/XMLHttpRequestTestBeans.xml?rev=783117&r1=783116&r2=783117&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/javascript/src/test/resources/XMLHttpRequestTestBeans.xml (original)
+++ cxf/branches/2.1.x-fixes/rt/javascript/src/test/resources/XMLHttpRequestTestBeans.xml Tue Jun 9 19:54:53 2009
@@ -1,29 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to you under the Apache License, Version
+ 2.0 (the "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed under the
+ License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+ CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the
+ License.
+ -->
<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:sec="http://cxf.apache.org/configuration/security"
- xmlns:http="http://cxf.apache.org/transports/http/configuration"
- xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
- xmlns:jaxws="http://cxf.apache.org/jaxws"
- xsi:schemaLocation="
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://cxf.apache.org/configuration/security"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xsi:schemaLocation="
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/configuration/security
@@ -34,37 +30,46 @@
http://cxf.apache.org/schemas/configuration/http-jetty.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
-
- <import resource="classpath:META-INF/cxf/cxf.xml" />
- <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
- <import resource="classpath:META-INF/cxf/cxf-extension-xml.xml" />
- <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
- <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
- <import resource="classpath:META-INF/cxf/cxf-extension-local.xml" />
-
- <httpj:engine-factory bus="cxf">
- <httpj:engine port="8808">
- <httpj:handlers>
- <bean class="org.mortbay.jetty.handler.ContextHandler">
- <property name="contextPath" value="/" />
- <property name="handler">
- <bean class="org.mortbay.jetty.handler.ResourceHandler">
- <property name="baseResource">
- <bean class="org.mortbay.resource.FileResource">
- <constructor-arg value="${staticResourceURL}" />
- </bean>
- </property>
- </bean>
- </property>
- </bean>
- <bean class="org.mortbay.jetty.handler.DefaultHandler"/>
- </httpj:handlers>
- </httpj:engine>
- </httpj:engine-factory>
-
- <jaxws:endpoint id="greeter-service-endpoint"
- implementor="org.apache.hello_world_xml_http.wrapped.GreeterImpl"
- address="http://localhost:8808/Greeter" >
- </jaxws:endpoint>
-
- </beans>
\ No newline at end of file
+
+ <import resource="classpath:META-INF/cxf/cxf.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-xml.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml" />
+ <import resource="classpath:META-INF/cxf/cxf-extension-local.xml" />
+
+ <httpj:engine-factory bus="cxf">
+ <httpj:engine port="8808">
+ <httpj:handlers>
+ <bean class="org.mortbay.jetty.handler.ContextHandler">
+ <property name="contextPath" value="/" />
+ <property name="handler">
+ <bean class="org.mortbay.jetty.handler.ResourceHandler">
+ <property name="baseResource">
+ <bean class="org.mortbay.resource.FileResource">
+ <constructor-arg value="${staticResourceURL}" />
+ </bean>
+ </property>
+ <property name="mimeTypes">
+ <bean class="org.mortbay.jetty.MimeTypes">
+ <property name="mimeMap">
+ <map>
+ <entry key="html"><value>text/html; charset="utf-8"</value></entry>
+ </map>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ <bean class="org.mortbay.jetty.handler.DefaultHandler" />
+ </httpj:handlers>
+ </httpj:engine>
+ </httpj:engine-factory>
+
+ <jaxws:endpoint id="greeter-service-endpoint"
+ implementor="org.apache.hello_world_xml_http.wrapped.GreeterImpl"
+ address="http://localhost:8808/Greeter">
+ </jaxws:endpoint>
+
+</beans>
\ No newline at end of file
Modified: cxf/branches/2.1.x-fixes/rt/javascript/src/test/resources/org/apache/cxf/javascript/XMLHttpRequestTests.js
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/javascript/src/test/resources/org/apache/cxf/javascript/XMLHttpRequestTests.js?rev=783117&r1=783116&r2=783117&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/javascript/src/test/resources/org/apache/cxf/javascript/XMLHttpRequestTests.js (original)
+++ cxf/branches/2.1.x-fixes/rt/javascript/src/test/resources/org/apache/cxf/javascript/XMLHttpRequestTests.js Tue Jun 9 19:54:53 2009
@@ -49,6 +49,7 @@
function testSyncHttpFetch() {
var r = new XMLHttpRequest();
+
r.open("GET", "http://localhost:8808/test.html", false);
if (r.readyState != r.OPENED) {
assertionFailed("state not OPENED after OPEN");
@@ -159,6 +160,7 @@
assertionFailed("state not OPENED after OPEN");
}
// just send it as text (or, really, whatever the Java code set up for us).
+ r.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
r.send(request);
if (r.readyState != r.DONE) {
assertionFailed("state not DONE after sync send.")
Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=783117&r1=783116&r2=783117&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java (original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java Tue Jun 9 19:54:53 2009
@@ -283,16 +283,18 @@
if (enc != null && enc.endsWith("\"")) {
enc = enc.substring(0, enc.length() - 1);
}
- String normalizedEncoding = HttpHeaderHelper.mapCharset(enc);
- if (normalizedEncoding == null) {
- String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG",
- LOG, enc).toString();
- LOG.log(Level.WARNING, m);
- throw new IOException(m);
+ if (enc != null || "POST".equals(req.getMethod()) || "PUT".equals(req.getMethod())) {
+ //allow gets/deletes/options to not specify an encoding
+ String normalizedEncoding = HttpHeaderHelper.mapCharset(enc);
+ if (normalizedEncoding == null) {
+ String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG",
+ LOG, enc).toString();
+ LOG.log(Level.WARNING, m);
+ throw new IOException(m);
+ }
+ inMessage.put(Message.ENCODING, normalizedEncoding);
}
- inMessage.put(Message.ENCODING, normalizedEncoding);
-
inMessage.put(Message.QUERY_STRING, req.getQueryString());
inMessage.put(Message.CONTENT_TYPE, contentType);
inMessage.put(Message.ACCEPT_CONTENT_TYPE, req.getHeader("Accept"));
Modified: cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java?rev=783117&r1=783116&r2=783117&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java (original)
+++ cxf/branches/2.1.x-fixes/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java Tue Jun 9 19:54:53 2009
@@ -227,7 +227,7 @@
}
}
- String normalizedEncoding = HttpHeaderHelper.mapCharset(enc);
+ String normalizedEncoding = HttpHeaderHelper.mapCharset(enc, "UTF-8");
if (normalizedEncoding == null) {
String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG", LOG, new Object[] {
enc