Skip to content

Commit 45364dd

Browse files
sideshowbarkerdomenic
authored andcommitted
Add an introductory API overview block for EventSource
This change adds a domintro block in the section that defines the EventSource interface. It also adds markup to cause more implementor-specific parts of the “Server-sent events” section to be suppressed in the developer edition.
1 parent 4c84bee commit 45364dd

File tree

1 file changed

+75
-3
lines changed

1 file changed

+75
-3
lines changed

source

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93595,6 +93595,8 @@ dictionary <dfn>EventSourceInit</dfn> {
9359593595
boolean <dfn data-x="dom-EventSourceInit-withCredentials">withCredentials</dfn> = false;
9359693596
};</pre>
9359793597

93598+
<div w-nodev>
93599+
9359893600
<p>Each <code>EventSource</code> object has the following associated with it:</p>
9359993601

9360093602
<ul>
@@ -93615,6 +93617,58 @@ dictionary <dfn>EventSourceInit</dfn> {
9361593617
<p>Apart from <span data-x="concept-EventSource-url">url</span> these are not currently exposed on
9361693618
the <code>EventSource</code> object.</p>
9361793619

93620+
</div>
93621+
93622+
<dl class="domintro">
93623+
93624+
<dt><var>source</var> = new <code subdfn data-x="dom-EventSource">EventSource</code>(
93625+
<var>url</var> [, { <code data-x="dom-EventSourceInit-withCredentials">withCredentials</code>:
93626+
true } ])</dt>
93627+
<dd>
93628+
<p>Creates a new <code>EventSource</code> object.</p>
93629+
93630+
<p><var>url</var> is a string giving the <span>URL</span> that will provide the event
93631+
stream.</p>
93632+
93633+
<p>Setting <code data-x="dom-EventSourceInit-withCredentials">withCredentials</code> to true
93634+
will set the <span data-x="concept-request-credentials-mode">credentials mode</span>
93635+
for connection requests to <var>url</var> to "<code data-x="">include</code>".</p>
93636+
</dd>
93637+
93638+
<dt><var>socket</var> . <code subdfn data-x="dom-EventSource-close">close</code>()</dt>
93639+
93640+
<dd>
93641+
<p>Aborts any instances of the <span data-x="concept-fetch">fetch</span> algorithm started for
93642+
this <code>EventSource</code> object, and sets the <code
93643+
data-x="dom-EventSource-readyState">readyState</code> attribute to <code
93644+
data-x="dom-EventSource-CLOSED">CLOSED</code>.</p>
93645+
</dd>
93646+
93647+
<dt><var>source</var> . <code subdfn data-x="dom-EventSource-url">url</code></dt>
93648+
93649+
<dd>
93650+
<p>Returns the <span data-x="concept-EventSource-url">URL providing the event stream</span>.
93651+
</dd>
93652+
93653+
<dt><var>source</var> . <code subdfn data-x="dom-EventSource-withCredentials">withCredentials</code></dt>
93654+
93655+
<dd>
93656+
<p>Returns true if the <span data-x="concept-request-credentials-mode">credentials mode</span>
93657+
for connection requests to the <span data-x="concept-EventSource-url">URL providing the
93658+
event stream</span> is set to "<code data-x="">include</code>", and false otherwise.</p>
93659+
</dd>
93660+
93661+
<dt><var>socket</var> . <code subdfn data-x="dom-EventSource-readyState">readyState</code></dt>
93662+
93663+
<dd>
93664+
<p>Returns the state of this <code>EventSource</code> object's connection. It can have the
93665+
values described below.</p>
93666+
</dd>
93667+
93668+
</dl>
93669+
93670+
<div w-nodev>
93671+
9361893672
<p>The <dfn><code data-x="dom-EventSource">EventSource(<var>url</var>,
9361993673
<var>eventSourceInitDict</var>)</code></dfn> constructor, when invoked, must run these steps:</p>
9362093674

@@ -93679,6 +93733,8 @@ dictionary <dfn>EventSourceInit</dfn> {
9367993733
<p>The <dfn><code data-x="dom-EventSource-readyState">readyState</code></dfn> attribute represents
9368093734
the state of the connection. It can have the following values:</p>
9368193735

93736+
</div>
93737+
9368293738
<dl>
9368393739

9368493740
<dt><dfn><code data-x="dom-EventSource-CONNECTING">CONNECTING</code></dfn> (numeric value 0)</dt>
@@ -93697,6 +93753,8 @@ dictionary <dfn>EventSourceInit</dfn> {
9369793753

9369893754
</dl>
9369993755

93756+
<div w-nodev>
93757+
9370093758
<p>When the object is created its <code data-x="dom-EventSource-readyState">readyState</code> must
9370193759
be set to <code data-x="dom-EventSource-CONNECTING">CONNECTING</code> (0). The rules given below
9370293760
for handling the connection define when the value changes.</p>
@@ -93708,6 +93766,8 @@ dictionary <dfn>EventSourceInit</dfn> {
9370893766
data-x="dom-EventSource-CLOSED">CLOSED</code>.</p> <!-- this also causes all the message events to
9370993767
stop firing, even if they were queued before close() was called -->
9371093768

93769+
</div>
93770+
9371193771
<p>The following are the <span>event handlers</span> (and their corresponding <span data-x="event
9371293772
handler event type">event handler event types</span>) <span w-nodev>that must be</span> supported,
9371393773
as <span>event handler IDL attributes</span>, by all objects implementing the
@@ -93724,6 +93784,7 @@ dictionary <dfn>EventSourceInit</dfn> {
9372493784

9372593785
<hr>
9372693786

93787+
<div w-nodev>
9372793788

9372893789
<h4 id="sse-processing-model"><span id="processing-model-9"></span>Processing model</h4>
9372993790

@@ -93863,8 +93924,12 @@ dictionary <dfn>EventSourceInit</dfn> {
9386393924
data-x="queue a task">queued</span> by <code>EventSource</code> objects is the <dfn>remote event
9386493925
task source</dfn>.</p>
9386593926

93927+
</div>
93928+
93929+
93930+
<h4 w-nodev>Parsing an event stream</h4>
9386693931

93867-
<h4>Parsing an event stream</h4>
93932+
<h4 w-nohtml>The event stream format</h4>
9386893933

9386993934
<p>This event stream format's <span>MIME type</span> is <code>text/event-stream</code>.</p>
9387093935

@@ -93894,13 +93959,15 @@ any-char = %x0000-0009 / %x000B-000C / %x000E-10FFFF
9389493959
pair, a single U+000A LINE FEED (LF) character, or a single U+000D CARRIAGE RETURN (CR)
9389593960
character.</p>
9389693961

93897-
<p>Since connections established to remote servers for such resources are expected to be
93962+
<p w-nodev>Since connections established to remote servers for such resources are expected to be
9389893963
long-lived, UAs should ensure that appropriate buffering is used. In particular, while line
9389993964
buffering with lines are defined to end with a single U+000A LINE FEED (LF) character is safe,
9390093965
block buffering or line buffering with different expected line endings can cause delays in event
9390193966
dispatch.</p>
9390293967

9390393968

93969+
<div w-nodev>
93970+
9390493971
<h4 id="event-stream-interpretation">Interpreting an event stream</h4>
9390593972

9390693973
<p>Streams must be decoded using the <span>UTF-8 decode</span> algorithm.</p>
@@ -94084,6 +94151,8 @@ any-char = %x0000-0009 / %x000B-000C / %x000E-10FFFF
9408494151
<p>For other user agents, the appropriate steps to <span>dispatch the event</span> are
9408594152
implementation dependent, but at a minimum they must set the <var>data</var> and <var>event type</var> buffers to the empty string before returning.</p>
9408694153

94154+
</div>
94155+
9408794156
<div class="example">
9408894157

9408994158
<p>The following event stream, once followed by a blank line:</p>
@@ -94169,7 +94238,7 @@ data:&nbsp;test
9416994238
</div>
9417094239

9417194240

94172-
<H4>Authoring notes</h4>
94241+
<h4>Authoring notes</h4>
9417394242

9417494243
<p>Legacy proxy servers are known to, in certain cases, drop HTTP connections after a short
9417594244
timeout. To protect against such proxy servers, authors can include a comment line (one starting
@@ -94194,6 +94263,7 @@ data:&nbsp;test
9419494263
functionality on a per-page basis, or by sharing a single <code>EventSource</code> object using a
9419594264
<span data-x="SharedWorkerGlobalScope">shared worker</span>.</p>
9419694265

94266+
<div w-nodev>
9419794267

9419894268
<h4 id="eventsource-push">Connectionless push and other features</h4>
9419994269

@@ -94303,6 +94373,8 @@ data:&nbsp;test
9430394373
consoles whenever an <code data-x="event-error">error</code> event is fired, since little to no
9430494374
information can be made available in the events themselves.</p>
9430594375

94376+
</div>
94377+
9430694378

9430794379
<h3 split-filename="web-sockets" id="network"><dfn>Web sockets</dfn></h3>
9430894380

0 commit comments

Comments
 (0)