Can fetch get object as headers?
<p>I am trying to understand how to use whatwg <code>fetch</code> according to specifications. Specifically, if I can do this, according to the specs.</p>

<pre><code>fetch("https://example.org", {headers:{'Content-Type', 'image/jpeg'}})
</code></pre>

<p>This is actually possible with <a href="https://github.com/github/fetch" rel="nofollow">github's fetch polyfill</a>, that is, according to their words, "as closely as possible to the standard Fetch specification".</p>

<p>When I read the <a href="https://developer.mozilla.org/en-US/docs/Web/API/GlobalFetch/fetch" rel="nofollow">MDN documentation</a>, I read this</p>

<blockquote>
  <p><code>headers</code>: Any headers you want to add to your request, contained within a <code>Headers</code> object or <code>ByteString</code>.</p>
</blockquote>

<p><em>(edit: I have now edited the MDN pages so they no longer talk about <code>Headers</code> initialization by <code>ByteString</code> directly.)</em></p>

<p>That means ordinary object is not allowed.</p>

<p>But, this documentation isn't perfect, so I went to the spec, that are written in their usual verbose way, and I find this:</p>

<p><a href="https://fetch.spec.whatwg.org/#request-class" rel="nofollow">https://fetch.spec.whatwg.org/#request-class</a></p>

<blockquote>
  <p>Request class</p>

<pre><code>Constructor(RequestInfo input, optional RequestInit init)

dictionary RequestInit {
...
  HeadersInit headers;
...
}

typedef (Headers or sequence&lt;sequence&lt;ByteString&gt;&gt; or OpenEndedDictionary&lt;ByteString&gt;) HeadersInit;
</code></pre>
  
  <p>OpenEndedDictionary is a future IDL construct. Expect it to be used
  as such:</p>

<pre><code>var meta = { "Content-Type": "text/xml", "Breaking-Bad": "&lt;3" }
new Headers(meta)
</code></pre>
</blockquote>

<p>If I read this correctly, this means that the object actually can be used (and <code>OpenEndedDictionary</code> is... just an object). Do I understand it correctly?</p>

<p>(I will add that, with my experimentation, both Firefox and Chrome accepts the header object.)</p>

<p>I also cannot see anything about the <code>headers</code> being possible to instantiate from <code>ByteString</code> directly as the MDN suggests.</p>

<p>What I am also interested is what the different implementations <em>actually</em> accept right now.</p>