title: Illegal characters in HTTP headers
body: <p>I'm creating an <code>HttpUrlConnection</code> and need to set multiple custom headers.</p>
  
  <p>I'd like to do something along the lines of the following, but the contents of the header map needs to come from a single string. Are there any characters that are illegal or extremely rarely used in both HTTP header names and HTTP header values?</p>
  
  <pre><code>HashMap&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
  
  // TODO: How can I fill the headers map reliably from a single string?
  
  HttpURLConnection c = (HttpURLConnection) url.openConnection();
  for(Map.Entry&lt;String, String&gt; e : headers.entrySet())
      c.setRequestProperty(e.getKey(), e.getValue());
  </code></pre>
  
  <hr>
  
  <p><strong>Solution for now</strong></p>
  
  <p>Doesn't seem like any HTTP header names contain any spaces (usually use dash instead?), so I can separate the name with the value using a single space. As for the name-value sets, it seems I'm screwed since the value can contain pretty much anything according to the given answer. So I've just picked a character I'm pretty sure will most likely never be used: <code>§</code>. If it turns out it is actually needed, I'll just have to adjust my code :p</p>
  
  <pre><code>Header1 Value1§Header2 Value2§Header3 Header3
  </code></pre>