title: Failed to execute 'setRequestHeader' on 'XMLHttpRequest' [...] is not a valid HTTP header field value
body: <p>I am developing an application with AngularJS (client side) and Java (server side) using RESTful services (with Jersey).</p>
  
  <p>In the client I have something like this</p>
  
  <pre><code>$http({
          url : "/Something/rest/...",
          method : "POST",
          headers : {
              ...
              'text' : text
          }
      });
  </code></pre>
  
  <p>on the server side my Java method header looks like this</p>
  
  <pre><code> public JSONObject myMethod(@HeaderParam("text") String text [...]) throws JSONException
  </code></pre>
  
  <p>And I'm getting this error when trying to send a request</p>
  
  <pre><code>Error: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'Some text here formatted with \n and \t' is not a valid HTTP header field value.
  </code></pre>
  
  <p>Is this because of the formatting? Is it because the text is quite long?</p>
  
  <p>What should I change? Please guide me</p>