You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2004/05/06 00:08:07 UTC

cvs commit: xml-xerces/c/src/xercesc/util/NetAccessors/libWWW BinURLInputStream.cpp BinURLInputStream.hpp LibWWWNetAccessor.cpp

amassari    2004/05/05 15:08:07

  Modified:    c/src/xercesc/util/NetAccessors/libWWW BinURLInputStream.cpp
                        BinURLInputStream.hpp LibWWWNetAccessor.cpp
  Log:
  Content reported by a web site as text/xml is now read correctly; added an extra way of getting the size of the document in case no redirection has been performed
  
  Revision  Changes    Path
  1.7       +18 -11    xml-xerces/c/src/xercesc/util/NetAccessors/libWWW/BinURLInputStream.cpp
  
  Index: BinURLInputStream.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/NetAccessors/libWWW/BinURLInputStream.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BinURLInputStream.cpp	16 Jan 2004 14:29:21 -0000	1.6
  +++ BinURLInputStream.cpp	5 May 2004 22:08:07 -0000	1.7
  @@ -56,6 +56,9 @@
   
   /**
    * $Log$
  + * Revision 1.7  2004/05/05 22:08:07  amassari
  + * Content reported by a web site as text/xml is now read correctly; added an extra way of getting the size of the document in case no redirection has been performed
  + *
    * Revision 1.6  2004/01/16 14:29:21  amassari
    * Removed usage of undeclared macro MIN
    *
  @@ -202,16 +205,21 @@
       BOOL  status = HTLoadToStream(uriAsCharStar, counterStrm, request);
       if (status == YES)
       {
  -        // Patch by Artur Klauser
  -        // When a redirection is processed in libWWW, it seems that
  -        // HTAnchor_length(anchor) == -1 on the original anchor, whereas
  -        // HTResponse_length(response) gives the correct content length of
  -        // the redirection target. This has confusedfRemoteFileSize and it was
  -        // not checked for a -1 response at all.
  -        HTResponse * response = HTRequest_response (request);
  -        fRemoteFileSize = HTResponse_length(response);
  -        if (fRemoteFileSize < 0) {
  -            ThrowXMLwithMemMgr(NetAccessorException, XMLExcepts::NetAcc_LengthError, fMemoryManager);
  +        HTParentAnchor * anchor = HTRequest_anchor(request);
  +        fRemoteFileSize=HTAnchor_length(anchor);
  +        if(fRemoteFileSize < 0)
  +        {
  +            // Patch by Artur Klauser
  +            // When a redirection is processed in libWWW, it seems that
  +            // HTAnchor_length(anchor) == -1 on the original anchor, whereas
  +            // HTResponse_length(response) gives the correct content length of
  +            // the redirection target. This has confused fRemoteFileSize and it was
  +            // not checked for a -1 response at all.
  +            HTResponse * response = HTRequest_response (request);
  +            fRemoteFileSize = HTResponse_length(response);
  +            if (fRemoteFileSize < 0) {
  +                ThrowXMLwithMemMgr(NetAccessorException, XMLExcepts::NetAcc_LengthError, fMemoryManager);
  +            }
           }
       }
   
  @@ -295,7 +303,6 @@
           fBytesProcessed += bytesAsked;
           retval = bytesAsked;
       }
  -
       else
       {
           // ...will need to read some more bytes out of the stream.
  
  
  
  1.6       +4 -1      xml-xerces/c/src/xercesc/util/NetAccessors/libWWW/BinURLInputStream.hpp
  
  Index: BinURLInputStream.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/NetAccessors/libWWW/BinURLInputStream.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BinURLInputStream.hpp	29 Jan 2004 11:51:20 -0000	1.5
  +++ BinURLInputStream.hpp	5 May 2004 22:08:07 -0000	1.6
  @@ -56,6 +56,9 @@
   
   /**
    * $Log$
  + * Revision 1.6  2004/05/05 22:08:07  amassari
  + * Content reported by a web site as text/xml is now read correctly; added an extra way of getting the size of the document in case no redirection has been performed
  + *
    * Revision 1.5  2004/01/29 11:51:20  cargilld
    * Code cleanup changes to get rid of various compiler diagnostic messages.
    *
  @@ -164,7 +167,7 @@
       XMLByte*            fBuffer;
       unsigned int        fBufferIndex;
       unsigned int        fBufferSize;
  -    unsigned int        fRemoteFileSize;
  +    int                 fRemoteFileSize;
       unsigned int        fBytesProcessed;
       MemoryManager*      fMemoryManager;
   };
  
  
  
  1.5       +12 -10    xml-xerces/c/src/xercesc/util/NetAccessors/libWWW/LibWWWNetAccessor.cpp
  
  Index: LibWWWNetAccessor.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/NetAccessors/libWWW/LibWWWNetAccessor.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LibWWWNetAccessor.cpp	24 Dec 2003 15:24:13 -0000	1.4
  +++ LibWWWNetAccessor.cpp	5 May 2004 22:08:07 -0000	1.5
  @@ -82,8 +82,10 @@
       // Initialize the libWWW library here.
       //
       HTProfile_newPreemptiveClient("XercesC", gXercesFullVersionStr);
  +    HTConversion_add(HTFormat_conversion(), "text/xml",         "*/*", HTThroughLine, 1.0, 0.0, 0.0);
  +    HTConversion_add(HTFormat_conversion(), "application/xml",  "*/*", HTThroughLine, 1.0, 0.0, 0.0);
   #ifdef XML_DEBUG
  -	HTSetTraceMessageMask("sop");
  +    HTSetTraceMessageMask("sop");
   #endif
       HTAlert_setInteractive(NO);
       HTHost_setEventTimeout(5000);
  @@ -94,13 +96,13 @@
   {
       // Cleanup the libWWW library here.
   
  -	/* Quote from http://www.w3.org/Library/src/HTProfil.html#Client:
  -	 *
  -	 * This call also supersedes the termination function for the
  -	 * Library core, HTLibTerminate() so that you don't have to call
  -	 * that after calling this function.
  -	 */
  -	HTProfile_delete();
  +    /* Quote from http://www.w3.org/Library/src/HTProfil.html#Client:
  +     *
  +     * This call also supersedes the termination function for the
  +     * Library core, HTLibTerminate() so that you don't have to call
  +     * that after calling this function.
  +    */
  +    HTProfile_delete();
   }
   
   
  @@ -112,7 +114,7 @@
           case XMLURL::HTTP:
           {
               BinURLInputStream* retStrm =
  -				new (urlSource.getMemoryManager()) BinURLInputStream(urlSource);
  +                new (urlSource.getMemoryManager()) BinURLInputStream(urlSource);
               return retStrm;
           }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org