From: Dave B. <bla...@us...> - 2013-02-06 15:01:07
|
Update of /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/io In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv11852/src/org/sblim/cimclient/internal/http/io Modified Files: DebugInputStream.java ChunkedInputStream.java Log Message: 3601894 Enhance HTTP and CIM-XML tracing Index: ChunkedInputStream.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/io/ChunkedInputStream.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- ChunkedInputStream.java 26 Nov 2012 13:22:15 -0000 1.12 +++ ChunkedInputStream.java 6 Feb 2013 15:01:05 -0000 1.13 @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2005, 2012 + * (C) Copyright IBM Corp. 2005, 2013 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE @@ -24,6 +24,7 @@ * 2524131 2009-01-21 raman_arora Upgrade client to JDK 1.5 (Phase 1) * 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 */ package org.sblim.cimclient.internal.http.io; @@ -44,6 +45,8 @@ private InputStream iIn; + private String iOrigin; + private long iChunkSize = 0; private boolean iEof = false; @@ -61,7 +64,20 @@ * The stream to create this one upon */ public ChunkedInputStream(InputStream pStream) { + this(pStream, null); + } + + /** + * Ctor. + * + * @param pStream + * The stream to create this one upon + * @param pOrigin + * The origin of the stream (response, indication request, etc.) + */ + public ChunkedInputStream(InputStream pStream, String pOrigin) { this.iIn = pStream; + this.iOrigin = pOrigin == null ? "Unknown" : pOrigin; } @Override @@ -117,7 +133,7 @@ this.iEof = true; this.iTrailers = new HttpHeader(this.iIn); // ebak: http trailers - this.iTrailers.examineTrailer(); + this.iTrailers.examineTrailer(this.iOrigin); } return total > 0 ? total : -1; } Index: DebugInputStream.java =================================================================== RCS file: /cvsroot/sblim/jsr48-client/src/org/sblim/cimclient/internal/http/io/DebugInputStream.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- DebugInputStream.java 6 Sep 2012 14:46:48 -0000 1.9 +++ DebugInputStream.java 6 Feb 2013 15:01:05 -0000 1.10 @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2005, 2012 + * (C) Copyright IBM Corp. 2005, 2013 * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE @@ -22,6 +22,7 @@ * 3062747 2010-09-21 blaschke-oss SblimCIMClient does not log all CIM-XML responces. * 3185833 2011-02-18 blaschke-oss missing newline when logging request/response * 3554738 2012-08-16 blaschke-oss dump CIM xml by LogAndTraceBroker.trace() + * 3601894 2013-01-23 blaschke-oss Enhance HTTP and CIM-XML tracing */ package org.sblim.cimclient.internal.http.io; @@ -50,6 +51,8 @@ private OutputStream iStream; + private String iOrigin; + /** * Ctor. * @@ -57,10 +60,22 @@ * @param os */ public DebugInputStream(InputStream is, OutputStream os) { + this(is, os, null); + } + + /** + * Ctor. + * + * @param is + * @param os + * @param pOrigin + */ + public DebugInputStream(InputStream is, OutputStream os, String pOrigin) { super(is); this.iBuf = new byte[512]; this.iBuffered = false; this.iStream = os; + this.iOrigin = pOrigin == null ? "unknown" : pOrigin; } private void buffer() throws IOException { @@ -77,10 +92,10 @@ } } catch (TrailerException e) { // TrailerException indicates complete response BUT error in trailer - writeBuffer("response begin (TrailerException occurred)"); + writeBuffer(this.iOrigin + " begin (TrailerException occurred)"); throw e; } - writeBuffer("response begin"); + writeBuffer(this.iOrigin + " begin"); } private void writeBuffer(String header) throws IOException { @@ -90,7 +105,10 @@ outStr.append(TimeStamp.formatWithMillis(System.currentTimeMillis())); outStr.append(" ----\n"); outStr.append(new String(this.iBuf, 0, this.iMaxLen)); - outStr.append("\n---- response end ----->\n"); + if (this.iMaxLen > 0 && this.iBuf[this.iMaxLen - 1] != '\n') outStr.append('\n'); + outStr.append("---- "); + outStr.append(this.iOrigin); + outStr.append(" end ----->\n"); if (this.iStream != null) this.iStream.write(outStr.toString().getBytes()); if (LogAndTraceBroker.getBroker().isLoggableCIMXMLTrace(Level.FINEST)) LogAndTraceBroker .getBroker().traceCIMXML(Level.FINEST, outStr.toString(), false); |