Author: kwright
Date: Tue Feb 25 12:51:21 2014
New Revision: 1571669

URL: http://svn.apache.org/r1571669
Log:
Finish CONNECTORS-901

Modified:
    manifoldcf/trunk/CHANGES.txt
    
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1571669&r1=1571668&r2=1571669&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Tue Feb 25 12:51:21 2014
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 1.6-dev =====================
 
+CONNECTORS-901: Clean up httpclient-related deprecation warnings.
+(Karl Wright)
+
 CONNECTORS-899: Allow some headers to be included/excluded from
 metadata for web connector.
 (Florian Schmedding, Karl Wright)

Modified: 
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java?rev=1571669&r1=1571668&r2=1571669&view=diff
==============================================================================
--- 
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
 (original)
+++ 
manifoldcf/trunk/framework/script-engine/src/main/java/org/apache/manifoldcf/scriptengine/ScriptParser.java
 Tue Feb 25 12:51:21 2014
@@ -34,8 +34,11 @@ import org.apache.http.impl.client.Defau
 import org.apache.http.impl.client.DefaultRedirectStrategy;
 import org.apache.http.conn.ClientConnectionManager;
 import org.apache.http.impl.conn.PoolingClientConnectionManager;
+import org.apache.http.entity.ContentType;
+import org.apache.http.ParseException;
 import java.util.*;
 import java.io.*;
+import java.nio.charset.Charset;
 
 /** Class to parse various syntactical parts of a script and execute them.
 */
@@ -59,6 +62,8 @@ public class ScriptParser
   /** A table of "new" operations that we know how to deal with. */
   protected Map<String,NewOperation> newOperations = new 
HashMap<String,NewOperation>();
 
+  protected final static Charset UTF_8 = Charset.forName("UTF-8");
+
   public ScriptParser()
   {
   }
@@ -1164,9 +1169,19 @@ public class ScriptParser
       InputStream is = entity.getContent();
       try
       {
-        String charSet = EntityUtils.getContentCharSet(entity);
-        if (charSet == null)
-          charSet = "utf-8";
+        Charset charSet;
+        try
+        {
+          ContentType ct = ContentType.get(entity);
+          if (ct == null)
+            charSet = UTF_8;
+          else
+            charSet = ct.getCharset();
+        }
+        catch (ParseException e)
+        {
+          charSet = UTF_8;
+        }
         char[] buffer = new char[65536];
         Reader r = new InputStreamReader(is,charSet);
         Writer w = new StringWriter();


Reply via email to