From: Dave B. <bla...@us...> - 2013-09-09 15:59:05
|
Update of /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv5765/src/org/sblim/cimclient/internal/http Modified Files: MessageReader.java HttpClient.java Log Message: 2655 Content-length must be ignored when Transfer-encoding present Index: MessageReader.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/MessageReader.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- MessageReader.java 30 May 2013 12:25:24 -0000 1.10 +++ MessageReader.java 9 Sep 2013 15:59:02 -0000 1.11 @@ -23,6 +23,7 @@ * 3601894 2013-01-23 blaschke-oss Enhance HTTP and CIM-XML tracing * 2621 2013-02-23 blaschke-oss Not all chunked input has trailers * 2635 2013-05-16 blaschke-oss Slowloris DoS attack for CIM indication listener port + * 2655 2013-08-14 blaschke-oss Content-length must be ignored when Transfer-encoding present */ package org.sblim.cimclient.internal.http; @@ -66,21 +67,18 @@ this.iMethod = new HttpServerMethod(pStream); this.iHeader = new HttpHeader(pStream, pTimeout); - // TODO: Add support for chunked, and bounded input stream String encoding = this.iHeader.getField("Transfer-Encoding"); if ((encoding != null) && (encoding.toLowerCase().endsWith("chunked"))) { this.iChunked = true; } String length = this.iHeader.getField("Content-Length"); int contentLength = -1; - if (length != null) { + if (length != null && length.length() > 0) { try { contentLength = Integer.parseInt(length); } catch (Exception e) { - contentLength = -1; - - LogAndTraceBroker logger = LogAndTraceBroker.getBroker(); - logger.trace(Level.FINER, "Exception while parsing http content-length", e); + LogAndTraceBroker.getBroker().trace(Level.FINER, + "Exception while parsing http content-length", e); } } String contentType = this.iHeader.getField("Content-Type"); @@ -91,18 +89,18 @@ } catch (Exception e) { encoding = "UTF-8"; // TODO is this the default character // encoding? - LogAndTraceBroker logger = LogAndTraceBroker.getBroker(); - logger.trace(Level.FINER, "Exception while parsing http content-type", e); + LogAndTraceBroker.getBroker().trace(Level.FINER, + "Exception while parsing http content-type", e); } this.iEncoding = encoding; } + + this.iContent = new PersistentInputStream(pStream, isPersistentConnectionSupported()); if (this.iChunked) { - this.iContent = new ChunkedInputStream(new PersistentInputStream(pStream, - isPersistentConnectionSupported()), this.iHeader.getField("Trailer"), + this.iContent = new ChunkedInputStream(this.iContent, this.iHeader.getField("Trailer"), "Indication Request"); - } else { - this.iContent = new BoundedInputStream(new PersistentInputStream(pStream, - isPersistentConnectionSupported()), contentLength); + } else if (contentLength >= 0) { + this.iContent = new BoundedInputStream(this.iContent, contentLength); } } Index: HttpClient.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/HttpClient.java,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- HttpClient.java 20 Aug 2013 12:10:53 -0000 1.49 +++ HttpClient.java 9 Sep 2013 15:59:02 -0000 1.50 @@ -72,6 +72,7 @@ * 2618 2013-02-27 blaschke-oss Need to add property to disable weak cipher suites for the secure indication * 2642 2013-05-21 blaschke-oss Seperate properties needed for cim client and listener to filter out ciphers * 2654 2013-07-29 blaschke-oss Check jcc idle time with CIMOM keepalive timeout to avoid EOF + * 2655 2013-08-14 blaschke-oss Content-length must be ignored when Transfer-encoding present */ package org.sblim.cimclient.internal.http; @@ -744,14 +745,17 @@ String transferEncoding = this.iResponseHeaders .getField("Transfer-encoding"); - - if (transferEncoding != null - && transferEncoding.toLowerCase().endsWith("chunked")) { - this.iServerInput = new ChunkedInputStream(this.iServerInput, - this.iResponseHeaders.getField("Trailer"), "Response"); - this.iKeepAlive = true; + if (transferEncoding != null) { + length = -1; // ignore Content-length + if (transferEncoding.toLowerCase().endsWith("chunked")) { + this.iServerInput = new ChunkedInputStream(this.iServerInput, + this.iResponseHeaders.getField("Trailer"), "Response"); + this.iKeepAlive = true; + } } - this.iServerInput = new BoundedInputStream(this.iServerInput, length); + + if (length >= 0) this.iServerInput = new BoundedInputStream( + this.iServerInput, length); logger.trace(Level.FINER, "KeepAlive=" + (this.iKeepAlive ? "true" : "false")); |