From 650732adaff82503b19a41b6c53d4299be9a1533 Mon Sep 17 00:00:00 2001 From: mcentner Date: Thu, 19 Nov 2009 13:37:10 +0000 Subject: Gracefully read the input stream. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@552 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../gv/egiz/bku/binding/HTTPBindingProcessor.java | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'bkucommon/src/main/java/at/gv') diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java index a1c4d5fc..b1906666 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java @@ -16,6 +16,8 @@ */ package at.gv.egiz.bku.binding; +import iaik.utils.Base64InputStream; + import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -551,7 +553,20 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements public InputStream getFormData(String aParameterName) { FormParameter fp = formParameterMap.get(aParameterName); if (fp != null) { - return fp.getFormParameterValue(); + final String enc = fp.getHeaderValue("Content-Transfer-Encoding"); + if (enc == null || "binary".equals(enc)) { + return fp.getFormParameterValue(); + } else if ("base64".equals(enc)) { + return new Base64InputStream(fp.getFormParameterValue()); + } else { + return new InputStream() { + @Override + public int read() throws IOException { + throw new IOException("Content-Transfer-Encoding : " + enc + + " is not supported."); + } + }; + } } return null; } @@ -679,12 +694,6 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements if (slCommand == null) { throw new SLBindingException(2004); } - if (is.read() != -1) { - log.error("Request input stream not completely read"); - // consume rest of stream, should never occur - throw new SLRuntimeException( - "request input stream not consumed till end"); - } } catch (SLException slx) { log.info("Error while consuming input stream " + slx); bindingProcessorError = slx; @@ -693,8 +702,10 @@ public class HTTPBindingProcessor extends AbstractBindingProcessor implements bindingProcessorError = new SLException(2000); } finally { try { - while (is.read() != -1) - ; + if (is.read() != -1) { + log.warn("Request input stream not completely read."); + while (is.read() != -1); + } } catch (IOException e) { log.error(e); } -- cgit v1.2.3