Uploaded image for project: 'XML-RPC'
  1. XML-RPC
  2. XMLRPC-164

HttpUtil.java readLine method possibly shouldn't use system default charset to create the return String for the input stream header line

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1.1
    • 3.1.2
    • None
    • None
    • IBM z/OS w/ JRE1.4.2

    Description

      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

      Attachments

        Activity

          People

            jochen@apache.org Jochen Wiedmann
            hackwurth Greg Wurth
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: