You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2011/07/13 06:10:25 UTC

svn commit: r1145854 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java

Author: hansbak
Date: Wed Jul 13 04:10:25 2011
New Revision: 1145854

URL: http://svn.apache.org/viewvc?rev=1145854&view=rev
Log:
https://issues.apache.org/jira/browse/OFBIZ-4337 : HttpClient does not support UTF-8 Patch By Chatree with comments from Adrian and Scott

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java?rev=1145854&r1=1145853&r2=1145854&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/HttpClient.java Wed Jul 13 04:10:25 2011
@@ -19,10 +19,10 @@
 package org.ofbiz.base.util;
 
 import java.io.BufferedReader;
-import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
 import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
@@ -48,6 +48,7 @@ public class HttpClient {
     private boolean keepAlive = false;
 
     private String contentType = null;
+    private String streamCharset = null;
     private String url = null;
     private String rawStream = null;
     private String clientCertAlias = null;
@@ -182,6 +183,16 @@ public class HttpClient {
     public String getContentType() {
         return this.contentType;
     }
+    
+    /** Sets the scream charset */
+    public void setStreamCharset(String streamCharset) {
+        this.streamCharset = streamCharset;
+    }
+    
+    /** Returns the stream charset */
+    public String getStreamCharset() {
+        return this.streamCharset;
+    }
 
     /** Toggle keep-alive setting */
     public void setKeepAlive(boolean keepAlive) {
@@ -464,11 +475,11 @@ public class HttpClient {
             }
 
             if (method.equalsIgnoreCase("post")) {
-                DataOutputStream out = new DataOutputStream(con.getOutputStream());
+                OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream(), this.streamCharset != null ? this.streamCharset : "UTF-8");
                 if (Debug.verboseOn() || debug) Debug.log("Opened output stream", module);
 
                 if (arguments != null) {
-                    out.writeBytes(arguments);
+                    out.write(arguments);
                     if (Debug.verboseOn() || debug) Debug.log("Wrote arguements (parameters) : " + arguments, module);
                 }