msmith      2002/10/24 20:24:34

  Modified:    src/webdav/client/src/org/apache/webdav/lib/methods
                        OptionsMethod.java
  Log:
  Don't try and parse an XML response body in an OPTIONS request unless there's
  some sign that there should be such a body from the headers. Avoids a
  "Fatal Error" being printed out on the console when using xerces 2.
  
  Revision  Changes    Path
  1.13      +16 -5     
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/OptionsMethod.java
  
  Index: OptionsMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/OptionsMethod.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- OptionsMethod.java        14 Aug 2002 15:22:24 -0000      1.12
  +++ OptionsMethod.java        25 Oct 2002 03:24:34 -0000      1.13
  @@ -200,6 +200,8 @@
       private Vector methodsAllowed = new Vector();
       
       private int type = 0;
  +
  +    private boolean hasXMLBody = false;
       
       
       // --------------------------------------------------------- Public Methods
  @@ -249,8 +251,8 @@
           throws IOException, HttpException {
           try
           {
  -            if (getStatusCode() == WebdavStatus.SC_OK ) {
  -                parseXMLResponse(input);
  +            if (getStatusCode() == WebdavStatus.SC_OK && hasXMLBody) {
  +                    parseXMLResponse(input);
               }
           }
           catch (IOException e) {
  @@ -295,6 +297,15 @@
                   methodsAllowed.addElement(methodAllowed);
               }
           }
  +
  +        Header lengthHeader = (Header) headers.get("content-length");
  +        Header typeHeader = (Header) headers.get("content-type");
  +        if(
  +                (lengthHeader != null && 
  +                 Integer.parseInt(lengthHeader.getValue()) > 0) || 
  +                (typeHeader != null && 
  +                 typeHeader.getValue().startsWith("text/xml")))
  +            hasXMLBody = true;
           
           super.processResponseHeaders(headers);
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:slide-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:slide-dev-help@;jakarta.apache.org>

Reply via email to