From: Dave B. <bla...@us...> - 2013-02-23 15:35:19
|
Update of /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/io In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv30409/src/org/sblim/cimclient/internal/http/io Modified Files: Tag: Experimental ChunkedInputStream.java Log Message: 2621 Not all chunked input has trailers Index: ChunkedInputStream.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/io/ChunkedInputStream.java,v retrieving revision 1.3.2.11 retrieving revision 1.3.2.12 diff -u -d -r1.3.2.11 -r1.3.2.12 --- ChunkedInputStream.java 23 Jan 2013 20:53:46 -0000 1.3.2.11 +++ ChunkedInputStream.java 23 Feb 2013 15:35:16 -0000 1.3.2.12 @@ -25,6 +25,7 @@ * 3304058 2011-05-20 blaschke-oss Use same date format in change history * 3557283 2012-11-05 blaschke-oss Print full response when get EOF from CIMOM * 3601894 2013-01-23 blaschke-oss Enhance HTTP and CIM-XML tracing + * 2621 2013-02-23 blaschke-oss Not all chunked input has trailers */ package org.sblim.cimclient.internal.http.io; @@ -45,6 +46,8 @@ private InputStream iIn; + private String iTrailerFields; + private String iOrigin; private long iChunkSize = 0; @@ -62,9 +65,11 @@ * * @param pStream * The stream to create this one upon + * @param pTrailerFields + * The names of trailer fields */ - public ChunkedInputStream(InputStream pStream) { - this(pStream, null); + public ChunkedInputStream(InputStream pStream, String pTrailerFields) { + this(pStream, pTrailerFields, null); } /** @@ -72,11 +77,14 @@ * * @param pStream * The stream to create this one upon + * @param pTrailerFields + * The names of trailer fields * @param pOrigin * The origin of the stream (response, indication request, etc.) */ - public ChunkedInputStream(InputStream pStream, String pOrigin) { + public ChunkedInputStream(InputStream pStream, String pTrailerFields, String pOrigin) { this.iIn = pStream; + this.iTrailerFields = pTrailerFields; this.iOrigin = pOrigin == null ? "Unknown" : pOrigin; } @@ -126,14 +134,24 @@ + (this.iChunkSize < len ? this.iChunkSize : len) + " bytes from HTTP chunk with remaining length of " + this.iChunkSize); - throw new EOFException("Unexpected EOF"); + throw new EOFException("Unexpected EOF reading chunk"); } } else { // read trailer this.iEof = true; - this.iTrailers = new HttpHeader(this.iIn); - // ebak: http trailers - this.iTrailers.examineTrailer(this.iOrigin); + if (this.iTrailerFields != null && this.iTrailerFields.trim().length() > 0) { + try { + this.iTrailers = new HttpHeader(this.iIn); + // ebak: http trailers + this.iTrailers.examineTrailer(this.iOrigin); + } catch (IOException e) { + LogAndTraceBroker.getBroker().trace( + Level.WARNING, + "Unexpected EOF reading trailer, expected fields were " + + this.iTrailerFields); + throw new EOFException("Unexpected EOF reading trailer"); + } + } } return total > 0 ? total : -1; } |