You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-auto@ws.apache.org by "Jochen Wiedmann (JIRA)" <xm...@ws.apache.org> on 2009/04/09 09:34:13 UTC

[jira] Resolved: (XMLRPC-164) HttpUtil.java readLine method possibly shouldn't use system default charset to create the return String for the input stream header line

     [ https://issues.apache.org/jira/browse/XMLRPC-164?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jochen Wiedmann resolved XMLRPC-164.
------------------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 3.1.1)
                   3.1.2
         Assignee: Jochen Wiedmann

Applied, with US-ASCII encoding. Thank you!


> HttpUtil.java readLine method possibly shouldn't use system default charset to create the return String for the input stream header line
> ----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XMLRPC-164
>                 URL: https://issues.apache.org/jira/browse/XMLRPC-164
>             Project: XML-RPC
>          Issue Type: Bug
>    Affects Versions: 3.1.1
>         Environment: IBM z/OS  w/ JRE1.4.2
>            Reporter: Greg Wurth
>            Assignee: Jochen Wiedmann
>            Priority: Minor
>             Fix For: 3.1.2
>
>
> I'm Running with a ServletWebServer on the z/OS platform and receive the following exception when processing new request:
> Jan 20, 2009 9:35:54 PM org.apache.xmlrpc.webserver.XmlRpcServlet log
> INFO: init
> Jan 20, 2009 9:35:54 PM org.apache.xmlrpc.server.XmlRpcErrorLogger log
> SEVERE: encoding 2: ISO-8859-1
> Jan 20, 2009 9:36:05 PM org.apache.xmlrpc.server.XmlRpcErrorLogger log
> SEVERE: 400 Bad Request
> org.apache.xmlrpc.webserver.ServletWebServer$Exception: 400 Bad Request
>         at org.apache.xmlrpc.webserver.HttpServletRequestImpl.<init>(HttpServletRequestImpl.java:163)
>         at org.apache.xmlrpc.webserver.ServletConnection.<init>(ServletConnection.java:50)
>         at org.apache.xmlrpc.webserver.ServletWebServer.newTask(ServletWebServer.java:145)
>         at org.apache.xmlrpc.webserver.WebServer.run(WebServer.java:329)
>         at java.lang.Thread.run(Thread.java:571)
> Jan 20, 2009 9:36:05 PM org.apache.xmlrpc.server.XmlRpcErrorLogger log
> SEVERE: 400 Bad Request
> org.apache.xmlrpc.webserver.ServletWebServer$Exception: 400 Bad Request
>         at org.apache.xmlrpc.webserver.HttpServletRequestImpl.<init>(HttpServletRequestImpl.java:163)
>         at org.apache.xmlrpc.webserver.ServletConnection.<init>(ServletConnection.java:50)
>         at org.apache.xmlrpc.webserver.ServletWebServer.newTask(ServletWebServer.java:145)
>         at org.apache.xmlrpc.webserver.WebServer.run(WebServer.java:329)
>         at java.lang.Thread.run(Thread.java:571)
> While tracing, I noticed that  the String returned from the readLine method in org.apache.xmlrpc.util.HttpUtil was actually in ebcidic, the default charset on z/OS.  This causes a problem in HttpServletRequestImpl while reading the input stream header.  HttpServletRequestImpl calls the HttpUtil.readLine method to get each input stream header line and then verifies that the line has a colon in it.  If there's not a colon the above exception is thrown.  
> I'm brand new to using xmlrpc and I don't if I'm using it improperly or not, but it seems that the readLine method in HttpUtil should use the webservlet's specified encoding or the ASCII charset to build the return String on not whatever the platforms default charset is.  When I updated the code to allow the "ISO-8859-1" or "US-ASCII" charset be specified in building the String, then the exception went away and everything worked like a charm.
> See my code change below in HttpUtil:
>   public static String readLine(InputStream pIn, byte[] pBuffer) throws IOException {
>     int next;
>     int count = 0;
>     while (true)
>     {
>       next = pIn.read();
>       if (next < 0 || next == '\n')
>       {
>         break;
>       }
>       if (next != '\r')
>       {
>         pBuffer[count++] = (byte) next;
>       }
>       if (count >= pBuffer.length)
>       {
>         throw new IOException ("HTTP Header too long");
>       }
>     }
>     return new String(pBuffer, 0, count);     ===>    Changed to       return new String(pBuffer, 0, count,"ISO-8859-1");
>   }
> The readLine method in HttpServletRequestImpl actually already does something like this (using the US-ASCII charset instead).
> I'm just using the buttermountain xmlrpc example that i believe was referenced on one of the apache xmlrpc pages.  
> I don't know if this is really a bug or if I just need to configure my environment differently.  I'm pretty new to Java on the zOS platform and know almost nothing about xmlrpc.  
> Thanks for your time!
> Greg

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.