diff options
author | mcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2009-11-19 13:37:10 +0000 |
---|---|---|
committer | mcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2009-11-19 13:37:10 +0000 |
commit | 650732adaff82503b19a41b6c53d4299be9a1533 (patch) | |
tree | e852e4b762356f48ba048beaa91cbb45fa6b7f1a | |
parent | 8814f7675055585933d8dae365cf3a95906fac05 (diff) | |
download | mocca-650732adaff82503b19a41b6c53d4299be9a1533.tar.gz mocca-650732adaff82503b19a41b6c53d4299be9a1533.tar.bz2 mocca-650732adaff82503b19a41b6c53d4299be9a1533.zip |
Gracefully read the input stream.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@552 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
-rw-r--r-- | bkucommon/src/main/java/at/gv/egiz/bku/binding/HTTPBindingProcessor.java | 29 |
1 files changed, 20 insertions, 9 deletions
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); } |