Author: kwright
Date: Mon Feb 24 00:44:14 2014
New Revision: 1571120
URL: http://svn.apache.org/r1571120
Log:
SharePoint connector fix for CONNECTORS-901
Modified:
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/sharepoint/CommonsHTTPSender.java
Modified:
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/sharepoint/CommonsHTTPSender.java
URL:
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/sharepoint/CommonsHTTPSender.java?rev=1571120&r1=1571119&r2=1571120&view=diff
==============================================================================
---
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/sharepoint/CommonsHTTPSender.java
(original)
+++
manifoldcf/trunk/connectors/sharepoint/connector/src/main/java/org/apache/manifoldcf/sharepoint/CommonsHTTPSender.java
Mon Feb 24 00:44:14 2014
@@ -48,12 +48,14 @@ import org.apache.http.params.HttpProtoc
import org.apache.http.ProtocolVersion;
import org.apache.http.util.EntityUtils;
import org.apache.http.message.BasicHeader;
+import org.apache.http.entity.ContentType;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.client.RedirectException;
import org.apache.http.client.CircularRedirectException;
import org.apache.http.NoHttpResponseException;
import org.apache.http.HttpException;
+import org.apache.http.ParseException;
import org.apache.commons.logging.Log;
@@ -80,6 +82,7 @@ import java.util.Iterator;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
+import java.nio.charset.Charset;
/* Class to use httpcomponents to communicate with a SOAP server.
* I've replaced the original rather complicated class with a much simpler one
that
@@ -95,6 +98,8 @@ public class CommonsHTTPSender extends B
protected static Log log =
LogFactory.getLog(CommonsHTTPSender.class.getName());
+ protected static final Charset UTF_8 = Charset.forName("UTF-8");
+
/** Properties */
protected CommonsHTTPClientProperties clientProperties;
@@ -360,9 +365,9 @@ public class CommonsHTTPSender extends B
{
try
{
- String charSet = methodThread.getCharSet();
+ Charset charSet = methodThread.getCharSet();
if (charSet == null)
- charSet = "utf-8";
+ charSet = UTF_8;
char[] buffer = new char[65536];
Reader r = new InputStreamReader(is,charSet);
Writer w = new StringWriter();
@@ -408,6 +413,7 @@ public class CommonsHTTPSender extends B
}
@Override
+ @Deprecated
public void consumeContent()
throws IOException {
EntityUtils.consume(this);
@@ -617,7 +623,7 @@ public class CommonsHTTPSender extends B
protected Throwable responseException = null;
protected XThreadInputStream threadStream = null;
protected InputStream bodyStream = null;
- protected String charSet = null;
+ protected Charset charSet = null;
protected boolean streamCreated = false;
protected Throwable streamException = null;
protected boolean abortThread = false;
@@ -683,7 +689,18 @@ public class CommonsHTTPSender extends B
if (bodyStream != null)
{
threadStream = new XThreadInputStream(bodyStream);
- charSet = EntityUtils.getContentCharSet(entity);
+ try
+ {
+ ContentType ct = ContentType.getOrDefault(entity);
+ if (ct == null)
+ charSet = null;
+ else
+ charSet = ct.getCharset();
+ }
+ catch (ParseException e)
+ {
+ charSet = null;
+ }
}
streamCreated = true;
}
@@ -858,7 +875,7 @@ public class CommonsHTTPSender extends B
}
}
- public String getCharSet()
+ public Charset getCharSet()
throws InterruptedException, IOException, HttpException
{
while (true)