title: Multiple lines in HTTP PUT Body (Inpustream) causes problems
body: <p>I have a method that receives the inputstream via HTTP Put and converts it into byte[] and sends it to another method called verifysignature. I have been having a weird problem with it. The code is all right, but however the message digests don't match. After debugging, I found out it works fine if my inpustream has a single line of text but fails when there are multiple lines.</p>
  
  <p>The request body of Http PUT looks like : </p>
  
  <pre><code>{
  "Url":"http://live.dev:3000/access_tokens",
  "AuthorizationUrl":"http://live.dev:3000/client_access_tokens",
  "Cert":"test"
  }
  </code></pre>
  
  <p>The method that responds to PUT request:</p>
  
  <pre><code>public @ResponseBody Map&lt;String,String&gt; createAuthorizationServer(HttpServletRequest request)throws IOException {
          // This method converts inputstream to byte[]
          byte[] inputStream = toBodyBytes(request.getInputStream());
          X509Certificate signingCert = null;
          //..... stuff
          // Here I am using the byte array
          signingCert = engine.verifySignature(signature,inputStream);
  </code></pre>
  
  <p>This works fine when the payload in request body is something in one line:</p>
  
  <pre><code>"test:;sample"
  </code></pre>
  
  <p>But fails when it has a multiple lines, like:</p>
  
  <pre><code>"test:;"
  "sample"
  </code></pre>
  
  <p>Can someone please throw some light at this? </p>
  
  <p><code>toBodyBytes</code> method for your reference:</p>
  
  <pre><code>private static byte[] toBodyBytes(InputStream inputStream) throws IOException {
          final int MAX_PAYLOAD_SIZE = 10240;
          byte[] buf = new byte[MAX_PAYLOAD_SIZE];
          // protect against OutOfMemoryError in case of  misconfiguration (accidentally filtering uploads)
          int bodySize = read(inputStream, buf, 0, buf.length);
          checkState(bodySize &lt; MAX_PAYLOAD_SIZE, "Looking for signature on upload payload?");
          return copyOf(buf, bodySize);
      }
  </code></pre>
  
  <p>Thank you!</p>