private void copyPayload(CachedOutputStream cos, final LogEvent event) { try { String encoding = (String) message.get(Message.ENCODING); StringBuilder payload = new StringBuilder(); writePayload(payload, cos, encoding, event.getContentType()); event.setPayload(payload.toString()); boolean isTruncated = cos.size() > limit && limit != -1; event.setTruncated(isTruncated); } catch (Exception ex) { // ignore } }
private void copyPayload(CachedOutputStream cos, final LogEvent event) { try { String encoding = (String) message.get(Message.ENCODING); StringBuilder payload = new StringBuilder(); writePayload(payload, cos, encoding, event.getContentType()); event.setPayload(payload.toString()); boolean isTruncated = cos.size() > limit && limit != -1; event.setTruncated(isTruncated); } catch (Exception ex) { // ignore } }
&& contentType.toLowerCase().indexOf("multipart/related") < 0) && cos.size() > 0) {
&& !contentType.toLowerCase().contains("multipart/related") && cos.size() > 0) {
/** * Read the entire original input stream and cache it. Useful * if switching threads or doing something where the original * stream may not be valid by the time the next read() occurs */ public void cacheInput() { if (!cached) { CachedOutputStream cache = new CachedOutputStream(); try { InputStream origIn = in; IOUtils.copy(in, cache); if (cache.size() > 0) { in = cache.getInputStream(); } else { in = new ByteArrayInputStream(new byte[0]); } cache.close(); origIn.close(); } catch (IOException e) { //ignore } cached = true; } }
private void handleOutputStream(final LogEvent event, Message message, CachedOutputStream cos) throws IOException { String encoding = (String) message.get(Message.ENCODING); if (StringUtils.isEmpty(encoding)) { encoding = StandardCharsets.UTF_8.name(); } StringBuilder payload = new StringBuilder(); cos.writeCacheTo(payload, encoding, limit); cos.close(); event.setPayload(payload.toString()); boolean isTruncated = cos.size() > limit && limit != -1; event.setTruncated(isTruncated); event.setFullContentFile(cos.getTempFile()); }
/** * Read the entire original input stream and cache it. Useful * if switching threads or doing something where the original * stream may not be valid by the time the next read() occurs */ public void cacheInput() { if (!cached) { CachedOutputStream cache = new CachedOutputStream(); try { InputStream origIn = in; IOUtils.copy(in, cache); if (cache.size() > 0) { in = cache.getInputStream(); } else { in = new ByteArrayInputStream(new byte[0]); } cache.close(); origIn.close(); } catch (IOException e) { //ignore } cached = true; } }
/** * Read the entire original input stream and cache it. Useful * if switching threads or doing something where the original * stream may not be valid by the time the next read() occurs */ public void cacheInput() { if (!cached) { CachedOutputStream cache = new CachedOutputStream(); try { InputStream origIn = in; IOUtils.copy(in, cache); if (cache.size() > 0) { in = cache.getInputStream(); } else { in = new ByteArrayInputStream(new byte[0]); } cache.close(); origIn.close(); } catch (IOException e) { //ignore } cached = true; } }
/** * Read the entire original input stream and cache it. Useful * if switching threads or doing something where the original * stream may not be valid by the time the next read() occurs */ public void cacheInput() { if (!cached) { CachedOutputStream cache = new CachedOutputStream(); try { InputStream origIn = in; IOUtils.copy(in, cache); if (cache.size() > 0) { in = cache.getInputStream(); } else { in = new ByteArrayInputStream(new byte[0]); } cache.close(); origIn.close(); } catch (IOException e) { //ignore } cached = true; } }
private void handleOutputStream(final LogEvent event, Message message, CachedOutputStream cos) throws IOException { String encoding = (String) message.get(Message.ENCODING); if (StringUtils.isEmpty(encoding)) { encoding = StandardCharsets.UTF_8.name(); } StringBuilder payload = new StringBuilder(); cos.writeCacheTo(payload, encoding, limit); cos.close(); event.setPayload(payload.toString()); boolean isTruncated = cos.size() > limit && limit != -1; event.setTruncated(isTruncated); event.setFullContentFile(cos.getTempFile()); }
@Override public void close() throws IOException { if (closed) { return; } closed = true; if (!chunking && wrappedStream instanceof CachedOutputStream) { CachedOutputStream out = (CachedOutputStream)wrappedStream; this.basicEntity.setContentLength(out.size()); wrappedStream = null; handleHeadersTrustCaching(); out.writeCacheTo(wrappedStream); } super.close(); }
/** * Copied from LoggingInInterceptor * * @param soapMessage */ private void getSoapRequest(Message soapMessage, ExchangeData exchange) { InputStream is = soapMessage.getContent(InputStream.class); if (is != null) { CachedOutputStream bos = new CachedOutputStream(); try { IOUtils.copy(is, bos); bos.flush(); is.close(); soapMessage.setContent(InputStream.class, bos.getInputStream()); StringBuilder builder = new StringBuilder(); bos.writeCacheTo(builder, bos.size()); bos.close(); exchange.setRequest(builder.toString()); exchange.setRequestSize((int)bos.size()); } catch (IOException e) { throw new Fault(e); } } }
if (cos.size() >= lim) { buffer.getMessage().append("(message truncated to " + lim + " bytes)\n"); buffer.getMessage().append("Outbound Message (saved to tmp file):\n"); buffer.getMessage().append("Filename: " + cos.getTempFile().getAbsolutePath() + "\n"); if (cos.size() >= lim) { buffer.getMessage().append("(message truncated to " + lim + " bytes)\n");
if (cos.getTempFile() == null) { if (cos.size() >= lim) { buffer.getMessage().append("(message truncated to " + lim + " bytes)\n"); truncated = true; buffer.getMessage().append("Outbound Message (saved to tmp file):\n"); buffer.getMessage().append("Filename: " + cos.getTempFile().getAbsolutePath() + "\n"); if (cos.size() >= lim) { buffer.getMessage().append("(message truncated to " + lim + " bytes)\n"); truncated = true;
if (os != osOriginal && os instanceof CachedOutputStream) { CachedOutputStream cos = (CachedOutputStream)os; if (cos.size() != 0) { cos.writeCacheTo(osOriginal);
if (bos.size() > limit && limit != -1) { buffer.getMessage().append("(message truncated to " + limit + " bytes)\n"); truncated = true;
if (os != osOriginal && os instanceof CachedOutputStream) { CachedOutputStream cos = (CachedOutputStream)os; if (cos.size() != 0) { cos.writeCacheTo(osOriginal);
if (bos.size() > limit && limit != -1) { buffer.getMessage().append("(message truncated to " + limit + " bytes)\n"); truncated = true;
buffer.getMessage().append("Filename: " + bos.getTempFile().getAbsolutePath() + "\n"); if (bos.size() > limit && limit != -1) { buffer.getMessage().append("(message truncated to " + limit + " bytes)\n");