forked from grmocg/SPDY-Specification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraft-mbelshe-httpbis-spdy-00.html
2167 lines (1967 loc) · 161 KB
/
draft-mbelshe-httpbis-spdy-00.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en"><head><title>SPDY Protocol</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="SPDY Protocol">
<meta name="keywords" content="HTTP">
<meta name="generator" content="xml2rfc v1.36 (http://xml.resource.org/)">
<style type='text/css'><!--
body {
font-family: verdana, charcoal, helvetica, arial, sans-serif;
font-size: small; color: #000; background-color: #FFF;
margin: 2em;
}
h1, h2, h3, h4, h5, h6 {
font-family: helvetica, monaco, "MS Sans Serif", arial, sans-serif;
font-weight: bold; font-style: normal;
}
h1 { color: #900; background-color: transparent; text-align: right; }
h3 { color: #333; background-color: transparent; }
td.RFCbug {
font-size: x-small; text-decoration: none;
width: 30px; height: 30px; padding-top: 2px;
text-align: justify; vertical-align: middle;
background-color: #000;
}
td.RFCbug span.RFC {
font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
font-weight: bold; color: #666;
}
td.RFCbug span.hotText {
font-family: charcoal, monaco, geneva, "MS Sans Serif", helvetica, verdana, sans-serif;
font-weight: normal; text-align: center; color: #FFF;
}
table.TOCbug { width: 30px; height: 15px; }
td.TOCbug {
text-align: center; width: 30px; height: 15px;
color: #FFF; background-color: #900;
}
td.TOCbug a {
font-family: monaco, charcoal, geneva, "MS Sans Serif", helvetica, sans-serif;
font-weight: bold; font-size: x-small; text-decoration: none;
color: #FFF; background-color: transparent;
}
td.header {
font-family: arial, helvetica, sans-serif; font-size: x-small;
vertical-align: top; width: 33%;
color: #FFF; background-color: #666;
}
td.author { font-weight: bold; font-size: x-small; margin-left: 4em; }
td.author-text { font-size: x-small; }
/* info code from SantaKlauss at http://www.madaboutstyle.com/tooltip2.html */
a.info {
/* This is the key. */
position: relative;
z-index: 24;
text-decoration: none;
}
a.info:hover {
z-index: 25;
color: #FFF; background-color: #900;
}
a.info span { display: none; }
a.info:hover span.info {
/* The span will display just on :hover state. */
display: block;
position: absolute;
font-size: smaller;
top: 2em; left: -5em; width: 15em;
padding: 2px; border: 1px solid #333;
color: #900; background-color: #EEE;
text-align: left;
}
a { font-weight: bold; }
a:link { color: #900; background-color: transparent; }
a:visited { color: #633; background-color: transparent; }
a:active { color: #633; background-color: transparent; }
p { margin-left: 2em; margin-right: 2em; }
p.copyright { font-size: x-small; }
p.toc { font-size: small; font-weight: bold; margin-left: 3em; }
table.toc { margin: 0 0 0 3em; padding: 0; border: 0; vertical-align: text-top; }
td.toc { font-size: small; font-weight: bold; vertical-align: text-top; }
ol.text { margin-left: 2em; margin-right: 2em; }
ul.text { margin-left: 2em; margin-right: 2em; }
li { margin-left: 3em; }
/* RFC-2629 <spanx>s and <artwork>s. */
em { font-style: italic; }
strong { font-weight: bold; }
dfn { font-weight: bold; font-style: normal; }
cite { font-weight: normal; font-style: normal; }
tt { color: #036; }
tt, pre, pre dfn, pre em, pre cite, pre span {
font-family: "Courier New", Courier, monospace; font-size: small;
}
pre {
text-align: left; padding: 4px;
color: #000; background-color: #CCC;
}
pre dfn { color: #900; }
pre em { color: #66F; background-color: #FFC; font-weight: normal; }
pre .key { color: #33C; font-weight: bold; }
pre .id { color: #900; }
pre .str { color: #000; background-color: #CFF; }
pre .val { color: #066; }
pre .rep { color: #909; }
pre .oth { color: #000; background-color: #FCF; }
pre .err { background-color: #FCC; }
/* RFC-2629 <texttable>s. */
table.all, table.full, table.headers, table.none {
font-size: small; text-align: center; border-width: 2px;
vertical-align: top; border-collapse: collapse;
}
table.all, table.full { border-style: solid; border-color: black; }
table.headers, table.none { border-style: none; }
th {
font-weight: bold; border-color: black;
border-width: 2px 2px 3px 2px;
}
table.all th, table.full th { border-style: solid; }
table.headers th { border-style: none none solid none; }
table.none th { border-style: none; }
table.all td {
border-style: solid; border-color: #333;
border-width: 1px 2px;
}
table.full td, table.headers td, table.none td { border-style: none; }
hr { height: 1px; }
hr.insert {
width: 80%; border-style: none; border-width: 0;
color: #CCC; background-color: #CCC;
}
--></style>
</head>
<body>
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<table summary="layout" width="66%" border="0" cellpadding="0" cellspacing="0"><tr><td><table summary="layout" width="100%" border="0" cellpadding="2" cellspacing="1">
<tr><td class="header">Network Working Group</td><td class="header">M. Belshe</td></tr>
<tr><td class="header">Internet-Draft</td><td class="header">Twist</td></tr>
<tr><td class="header">Expires: February 2, 2013</td><td class="header">R. Peon</td></tr>
<tr><td class="header"> </td><td class="header">Google, Inc</td></tr>
<tr><td class="header"> </td><td class="header">August 2012</td></tr>
</table></td></tr></table>
<h1><br />SPDY Protocol<br />draft-mbelshe-httpbis-spdy-00</h1>
<h3>Abstract</h3>
<p>This document describes SPDY, a protocol designed for low-latency transport of content over the World Wide Web. SPDY introduces two layers of protocol. The lower layer is a general purpose framing layer which can be used atop a reliable transport (likely TCP) for multiplexed, prioritized, and compressed data communication of many concurrent streams. The upper layer of the protocol provides HTTP-like semantics for compatibility with existing HTTP application servers.
</p>
<h3>Status of this Memo</h3>
<p>
This Internet-Draft is submitted in full
conformance with the provisions of BCP 78 and BCP 79.</p>
<p>
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current
Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.</p>
<p>
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any time.
It is inappropriate to use Internet-Drafts as reference material or to cite
them other than as “work in progress.”</p>
<p>
This Internet-Draft will expire on February 2, 2013.</p>
<h3>Copyright Notice</h3>
<p>
Copyright (c) 2012 IETF Trust and the persons identified as the
document authors. All rights reserved.</p>
<p>
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.</p>
<a name="toc"></a><br /><hr />
<h3>Table of Contents</h3>
<p class="toc">
<a href="#intro">1.</a>
Overview<br />
<a href="#anchor1">1.1.</a>
Document Organization<br />
<a href="#anchor2">1.2.</a>
Definitions<br />
<a href="#FramingLayer">2.</a>
SPDY Framing Layer<br />
<a href="#anchor3">2.1.</a>
Session (Connections)<br />
<a href="#anchor4">2.2.</a>
Framing<br />
<a href="#NotationalConventions">2.2.1.</a>
Notational Conventions for Framing<br />
<a href="#ControlFrames">2.2.2.</a>
Control frames<br />
<a href="#DataFrames">2.2.3.</a>
Data frames<br />
<a href="#anchor5">2.3.</a>
Streams<br />
<a href="#StreamFrames">2.3.1.</a>
Stream frames<br />
<a href="#StreamCreation">2.3.2.</a>
Stream creation<br />
<a href="#StreamPriority">2.3.3.</a>
Stream priority<br />
<a href="#anchor8">2.3.4.</a>
Stream headers<br />
<a href="#anchor9">2.3.5.</a>
Stream data exchange<br />
<a href="#StreamHalfClose">2.3.6.</a>
Stream half-close<br />
<a href="#StreamClose">2.3.7.</a>
Stream close<br />
<a href="#anchor10">2.4.</a>
Error Handling<br />
<a href="#SessionErrorHandler">2.4.1.</a>
Session Error Handling<br />
<a href="#StreamErrorHandler">2.4.2.</a>
Stream Error Handling<br />
<a href="#anchor11">2.5.</a>
Data flow<br />
<a href="#ControlFrameTypes">2.6.</a>
Control frame types<br />
<a href="#SYN_STREAM">2.6.1.</a>
SYN_STREAM<br />
<a href="#SYN_REPLY">2.6.2.</a>
SYN_REPLY<br />
<a href="#RST_STREAM">2.6.3.</a>
RST_STREAM<br />
<a href="#SETTINGS">2.6.4.</a>
SETTINGS<br />
<a href="#PING">2.6.5.</a>
PING<br />
<a href="#GOAWAY">2.6.6.</a>
GOAWAY<br />
<a href="#HEADERS">2.6.7.</a>
HEADERS<br />
<a href="#WINDOW_UPDATE">2.6.8.</a>
WINDOW_UPDATE<br />
<a href="#CREDENTIAL">2.6.9.</a>
CREDENTIAL<br />
<a href="#PUSH_PROMISE">2.6.10.</a>
PUSH_PROMISE<br />
<a href="#HeaderBlock">2.6.11.</a>
Name/Value Header Block<br />
<a href="#HTTPLayer">3.</a>
HTTP Layering over SPDY<br />
<a href="#anchor12">3.1.</a>
Connection Management<br />
<a href="#anchor13">3.1.1.</a>
Use of GOAWAY<br />
<a href="#anchor14">3.2.</a>
HTTP Request/Response<br />
<a href="#anchor15">3.2.1.</a>
Request<br />
<a href="#anchor16">3.2.2.</a>
Response<br />
<a href="#Authentication">3.2.3.</a>
Authentication<br />
<a href="#anchor19">3.3.</a>
Server Push Transactions<br />
<a href="#anchor20">3.3.1.</a>
Server implementation<br />
<a href="#anchor21">3.3.2.</a>
Client implementation<br />
<a href="#WebSocketLayer">4.</a>
WebSocket Layering over SPDY<br />
<a href="#anchor22">4.1.</a>
Connection Management<br />
<a href="#anchor23">4.1.1.</a>
Opening Handshake<br />
<a href="#anchor26">4.1.2.</a>
Closing Handshake<br />
<a href="#anchor29">4.2.</a>
Bi-directional Communication<br />
<a href="#anchor30">4.2.1.</a>
Frame mapping<br />
<a href="#anchor31">5.</a>
Design Rationale and Notes<br />
<a href="#anchor32">5.1.</a>
Separation of Framing Layer and Application Layer<br />
<a href="#anchor33">5.2.</a>
Error handling - Framing Layer<br />
<a href="#anchor34">5.3.</a>
One Connection Per Domain<br />
<a href="#anchor35">5.4.</a>
Fixed vs Variable Length Fields<br />
<a href="#anchor36">5.5.</a>
Compression Context(s)<br />
<a href="#anchor37">5.6.</a>
Unidirectional streams<br />
<a href="#anchor38">5.7.</a>
Data Compression<br />
<a href="#anchor39">5.8.</a>
Server Push<br />
<a href="#anchor40">6.</a>
Security Considerations<br />
<a href="#anchor41">6.1.</a>
Use of Same-origin constraints<br />
<a href="#anchor42">6.2.</a>
HTTP Headers and SPDY Headers<br />
<a href="#anchor43">6.3.</a>
Cross-Protocol Attacks<br />
<a href="#anchor44">6.4.</a>
Server Push Implicit Headers<br />
<a href="#anchor45">7.</a>
Privacy Considerations<br />
<a href="#anchor46">7.1.</a>
Long Lived Connections<br />
<a href="#anchor47">7.2.</a>
SETTINGS frame<br />
<a href="#anchor48">8.</a>
Sub-protocol negotiation<br />
<a href="#anchor49">8.1.</a>
Supporting scheme negotiation using SETTINGS frame<br />
<a href="#anchor50">9.</a>
Incompatibilities with SPDY draft #3<br />
<a href="#anchor51">10.</a>
Requirements Notation<br />
<a href="#anchor52">11.</a>
Acknowledgements<br />
<a href="#rfc.references1">12.</a>
Normative References<br />
<a href="#anchor54">Appendix A.</a>
Changes<br />
<a href="#rfc.authors">§</a>
Authors' Addresses<br />
</p>
<br clear="all" />
<a name="intro"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1"></a><h3>1.
Overview</h3>
<p>One of the bottlenecks of HTTP implementations is that HTTP relies on multiple connections for concurrency. This causes several problems, including additional round trips for connection setup, slow-start delays, and connection rationing by the client, where it tries to avoid opening too many connections to any single server. HTTP pipelining helps some, but only achieves partial multiplexing. In addition, pipelining has proven non-deployable in existing browsers due to intermediary interference.
</p>
<p>SPDY adds a framing layer for multiplexing multiple, concurrent streams across a single TCP connection (or any reliable transport stream). The framing layer is optimized for HTTP-like request-response streams, such that applications which run over HTTP today can work over SPDY with little or no change on behalf of the web application writer.
</p>
<p>The SPDY session offers four improvements over HTTP:
</p>
<blockquote class="text">
<p>Multiplexed requests: There is no limit to the number of requests that can be issued concurrently over a single SPDY connection.
</p>
<p>Prioritized requests: Clients can request certain resources to be delivered first. This avoids the problem of congesting the network channel with non-critical resources when a high-priority request is pending.
</p>
<p>Compressed headers: Clients today send a significant amount of redundant data in the form of HTTP headers. Because a single web page may require 50 or 100 subrequests, this data is significant.
</p>
<p>Server pushed streams: Server Push enables content to be pushed from servers to clients without a request.
</p>
</blockquote><p>
</p>
<p>SPDY attempts to preserve the existing semantics of HTTP. All features such as cookies, ETags, Vary headers, Content-Encoding negotiations, etc work as they do with HTTP; SPDY only replaces the way the data is written to the network.
</p>
<a name="anchor1"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.1"></a><h3>1.1.
Document Organization</h3>
<p>The SPDY Specification is split into two parts: <a class='info' href='#FramingLayer'>a framing layer<span> (</span><span class='info'>SPDY Framing Layer</span><span>)</span></a>, which multiplexes a TCP connection into independent, length-prefixed frames, and <a class='info' href='#HTTPLayer'>an HTTP layer<span> (</span><span class='info'>HTTP Layering over SPDY</span><span>)</span></a>, which specifies the mechanism for overlaying HTTP request/response pairs on top of the framing layer. While some of the framing layer concepts are isolated from the HTTP layer, building a generic framing layer has not been a goal. The framing layer is tailored to the needs of the HTTP protocol and server push.
</p>
<a name="anchor2"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.1.2"></a><h3>1.2.
Definitions</h3>
<p>
</p>
<blockquote class="text">
<p>client: The endpoint initiating the SPDY session.
</p>
<p>connection: A transport-level connection between two endpoints.
</p>
<p>endpoint: Either the client or server of a connection.
</p>
<p>frame: A header-prefixed sequence of bytes sent over a SPDY session.
</p>
<p>server: The endpoint which did not initiate the SPDY session.
</p>
<p>session: A synonym for a connection.
</p>
<p>session error: An error on the SPDY session.
</p>
<p>stream: A potentially bi-directional flow of bytes across a virtual channel within a SPDY session.
</p>
<p>stream error: An error on an individual SPDY stream.
</p>
</blockquote><p>
</p>
<a name="FramingLayer"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2"></a><h3>2.
SPDY Framing Layer</h3>
<a name="anchor3"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.1"></a><h3>2.1.
Session (Connections)</h3>
<p>The SPDY framing layer (or "session") runs atop a reliable transport layer such as <a class='info' href='#RFC0793'>TCP<span> (</span><span class='info'>Postel, J., “Transmission Control Protocol,” September 1981.</span><span>)</span></a> [RFC0793]. The client is the TCP connection initiator. SPDY connections are persistent connections.
</p>
<p>For best performance, it is expected that non-battery operated clients will leave open connections until the user navigates away from all web pages referencing the connection, or until the server closes the connection. Servers are encouraged to leave connections open for as long as possible, but can terminate idle connections if necessary. When either endpoint closes the transport-level connection, it MUST first send a <a class='info' href='#GOAWAY'>GOAWAY<span> (</span><span class='info'>GOAWAY</span><span>)</span></a> frame so that the endpoints can reliably determine if requests finished before the close. It is expected that battery-operated clients may have more involved heuristics as to when a connection should be closed.
</p>
<a name="anchor4"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.2"></a><h3>2.2.
Framing</h3>
<p>Once the connection is established, clients and servers exchange framed messages. There are two types of frames: <a class='info' href='#ControlFrames'>control frames<span> (</span><span class='info'>Control frames</span><span>)</span></a> and <a class='info' href='#DataFrames'>data frames<span> (</span><span class='info'>Data frames</span><span>)</span></a>.
</p>
<p>Both types of frames carry a common set of headers: length, flags, and frame type. Flag definitions vary between control and data frames. The simple header is designed to make reading and writing of frames easy.
</p>
<p>All integer values, including length, and type, are in network byte order. SPDY does not enforce alignment of types in dynamically sized frames.
</p>
<a name="NotationalConventions"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.2.1"></a><h3>2.2.1.
Notational Conventions for Framing</h3>
<p> In SPDY, since everything is defined to be in network byte-order, the most significant bit of any field is the "leftmost" in any diagram.
</p>
<blockquote class="text">
<p> "+" denotes the boundary of a byte (synonomous with octet in this document)
</p>
<p> "-" denotes a bit
</p>
<p> "=" denotes an unknown number of bits, typically bounded by one of the fields in the frame definition
</p>
<p> "|" denotes field separation, which may or may not be on a byte boundary. This does not count as a bit
</p>
<p> "->" at the end of a line indicates that the structure is not yet fully described
</p>
<p> "(N)" indicates that the field is N bits long
</p>
<p> "[Foo]" advises that the field is the Foo field for that frame
</p>
<p> "X" represents a reserved bit. It MUST be zeroed
</p>
<p> A number preceeded by "0x" is a hexidecimal number
</p>
<p> A number which is not preceeded by "0x" is to be interpreted as binary
</p>
<p> The numbers above the boxes indicate the byte-offset from the start of that frame or section, as appropriate
</p>
</blockquote><p>
</p>
<p> As an example:
</p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
0 1 2 3
+--|------+--|------+--------+--------+
|10|[PRI]0xEE|XXXXXX| Len(16) |
+--|------+--|------+--------+--------+
</pre></div><p>
This describes a frame which starts with 1 as the MSB, a 0 in the second most significant bit, followed by 0b11101110 (or 0xEE) as the "PRI" field, followed by 6 reserved bits, which will have all be zeroed, followed by a Len field which is 16 bits long.
In other words, first two bytes would be: 0b10111011 0b10000000, followed by the Len field.
</p>
<p>
Another example. In this case, a single byte is represented with the most significant bit a 0, the second most significant bit a 1, the next bit the 'K' field, the next bit the 'L' field, and the next 4 bits are reserved and must be zeros. The frame description continues, describing that an indeterminate (presumably defined elsewhere) amount of data follows and ends on a byte boundary.
</p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
0
+--|-|-|----+
|01|K|L|XXXX| ->
+--|-|-|----+
1..N
+========+
| data |
+========+
</pre></div><p>
</p>
<a name="ControlFrames"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.2.2"></a><h3>2.2.2.
Control frames</h3>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
0 1 2 3 4 5 6 7
+--------+--------+--------+-|-------+--------+--------+--------+--------+
| Length(16) |Flags(8)|1| Num-of-Entries-or-Stream-ID-or-ID|Type(8) | ->
+--------+--------+--------+-|-------+--------+--------+--------+--------+
8..N
+========+
| Data |
+========+
</pre></div>
<p>Control bit: The 'C' bit is a single bit indicating if this is a control message. For control frames this value is always 1.
</p>
<p>Type: The type of control frame. See <a class='info' href='#ControlFrameTypes'>Control Frames<span> (</span><span class='info'>Control frame types</span><span>)</span></a> for the complete list of control frames.
</p>
<p>Flags: Flags related to this frame. Flags for control frames and data frames are different.
</p>
<p>Length: An unsigned 16-bit value representing the number of bytes after the length field.
</p>
<p>Data: data associated with this control frame. The format and length of this data is controlled by the control frame type.
</p>
<p>Control frame processing requirements:
</p>
<blockquote class="text">
<p>Note that full length control frames (16kb) can be large for implementations running on resource-limited hardware. In such cases, implementations MAY limit the maximum length frame supported. However, all implementations MUST be able to receive control frames of at least 8192 octets in length.
</p>
</blockquote><p>
</p>
<a name="DataFrames"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.2.3"></a><h3>2.2.3.
Data frames</h3>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
0 1 2 3 4 5 6 7..N
+--------+--------+--------+-|-------+--------+--------+--------+========+
| Length(16) |Flags(8)|0| Stream ID (31) | Data |
+--------+--------+--------+-|-------+--------+--------+--------+========+
</pre></div>
<p>Control bit: For data frames this value is always 0.
</p>
<p>Stream-ID: A 31-bit value identifying the stream.
</p>
<p>Flags: Flags related to this frame. Valid flags are:
</p>
<blockquote class="text">
<p>0x01 = FLAG_FIN - signifies that this frame represents the last frame to be transmitted on this stream. See <a class='info' href='#StreamClose'>Stream Close<span> (</span><span class='info'>Stream close</span><span>)</span></a> below.
</p>
<p>0x02 = MSG_DONE - signifies that this frame represents the last frame of a message. This is relevant for layering of message-based protocols on top of SPDY.
</p>
</blockquote><p>
</p>
<p>Length: An unsigned 16-bit value representing the number of bytes after the length field. The total size of a data frame is 8 bytes + length. It is valid to have a zero-length data frame.
</p>
<p>Data: The variable-length data payload; the length was defined in the length field.
</p>
<p>Data frame processing requirements:
</p>
<blockquote class="text">
<p>If an endpoint receives a data frame for a stream-id which is not open and the endpoint has not sent a <a class='info' href='#GOAWAY'>GOAWAY<span> (</span><span class='info'>GOAWAY</span><span>)</span></a> frame, it MUST issue a <a class='info' href='#StreamErrorHandler'>stream error<span> (</span><span class='info'>Stream Error Handling</span><span>)</span></a> with the error code INVALID_STREAM for the stream-id.
</p>
<p>If the endpoint which created the stream receives a data frame before receiving a SYN_REPLY on that stream, it is a protocol error, and the recipient MUST issue a <a class='info' href='#StreamErrorHandler'>stream error<span> (</span><span class='info'>Stream Error Handling</span><span>)</span></a> with the status code PROTOCOL_ERROR for the stream-id.
</p>
<p>Implementors note: If an endpoint receives multiple data frames for invalid stream-ids, it MAY close the session.
</p>
</blockquote><p>
</p>
<a name="anchor5"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3"></a><h3>2.3.
Streams</h3>
<p>Streams are independent sequences of bi-directional data divided into frames with several properties:
</p>
<blockquote class="text">
<p>Streams may be created by either the client or server.
</p>
<p>Streams optionally carry a set of name/value header pairs.
</p>
<p>Streams can concurrently send data interleaved with other streams.
</p>
<p>Streams may be cancelled.
</p>
</blockquote><p>
</p>
<a name="StreamFrames"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3.1"></a><h3>2.3.1.
Stream frames</h3>
<p>SPDY defines 3 control frames to manage the lifecycle of a stream:
</p>
<blockquote class="text">
<p>SYN_STREAM - Open a new stream
</p>
<p>SYN_REPLY - Remote acknowledgement of a new, open stream
</p>
<p>RST_STREAM - Close a stream
</p>
</blockquote><p>
</p>
<a name="StreamCreation"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3.2"></a><h3>2.3.2.
Stream creation</h3>
<p>A stream is created by sending a control frame with the type set to <a class='info' href='#SYN_STREAM'>SYN_STREAM<span> (</span><span class='info'>SYN_STREAM</span><span>)</span></a>. If the server is initiating the stream, the Stream-ID must be even. If the client is initiating the stream, the Stream-ID must be odd. 0 is not a valid Stream-ID. Stream-IDs from each side of the connection must increase monotonically as new streams are created. E.g. Stream 2 may be created after stream 3, but stream 7 must not be created after stream 9. Stream IDs do not wrap: when a client or server cannot create a new stream id without exceeding a 31 bit value, it MUST NOT create a new stream.
</p>
<p>The stream-id MUST increase with each new stream. If an endpoint receives a SYN_STREAM with a stream id which is less than any previously received SYN_STREAM, it MUST issue a <a class='info' href='#SessionErrorHandler'>session error<span> (</span><span class='info'>Session Error Handling</span><span>)</span></a> with the status PROTOCOL_ERROR.
</p>
<p>It is a protocol error to send two SYN_STREAMs with the same stream-id. If a recipient receives a second SYN_STREAM for the same stream, it MUST issue a <a class='info' href='#StreamErrorHandler'>stream error<span> (</span><span class='info'>Stream Error Handling</span><span>)</span></a> with the status code PROTOCOL_ERROR.
</p>
<p>Upon receipt of a SYN_STREAM, the recipient can reject the stream by sending a <a class='info' href='#StreamErrorHandler'>stream error<span> (</span><span class='info'>Stream Error Handling</span><span>)</span></a> with the error code REFUSED_STREAM. Note, however, that the creating endpoint may have already sent additional frames for that stream which cannot be immediately stopped.
</p>
<p>Once the stream is created, the creator may immediately send HEADERS or DATA frames for that stream, without needing to wait for the recipient to acknowledge.
</p>
<a name="anchor6"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3.2.1"></a><h3>2.3.2.1.
Unidirectional streams</h3>
<p>When an endpoint creates a stream that includes an Associated-To-Stream-ID, it creates a unidirectional stream which the creating endpoint can use to send frames, but the receiving endpoint cannot. The receiving endpoint is implicitly already in the <a class='info' href='#StreamHalfClose'>half-closed<span> (</span><span class='info'>Stream half-close</span><span>)</span></a> state.
</p>
<a name="anchor7"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3.2.2"></a><h3>2.3.2.2.
Bidirectional streams</h3>
<p>SYN_STREAM frames which do not include an Associated-To-Stream-ID are bidirectional streams. Both endpoints can send data on a bi-directional stream.
</p>
<a name="StreamPriority"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3.3"></a><h3>2.3.3.
Stream priority</h3>
<p>The creator of a stream assigns a priority for that stream. Priority is represented as an integer from 0 to 7. 0 represents the highest priority and 7 represents the lowest priority.
</p>
<p>The sender and recipient SHOULD use best-effort to process streams in the order of highest priority to lowest priority.
</p>
<a name="anchor8"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3.4"></a><h3>2.3.4.
Stream headers</h3>
<p>Streams carry optional sets of name/value pair headers which carry metadata about the stream. After the stream has been created, and as long as the sender is not <a class='info' href='#StreamClose'>closed<span> (</span><span class='info'>Stream close</span><span>)</span></a> or <a class='info' href='#StreamHalfClose'>half-closed<span> (</span><span class='info'>Stream half-close</span><span>)</span></a>, each side may send HEADERS frame(s) containing the header data. Header data can be sent in multiple HEADERS frames, and HEADERS frames may be interleaved with data frames.
</p>
<a name="anchor9"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3.5"></a><h3>2.3.5.
Stream data exchange</h3>
<p>Once a stream is created, it can be used to send arbitrary amounts of data. Generally this means that a series of data frames will be sent on the stream until a frame containing the FLAG_FIN flag is set. The FLAG_FIN can be set on a <a class='info' href='#SYN_STREAM'>SYN_STREAM<span> (</span><span class='info'>SYN_STREAM</span><span>)</span></a>, <a class='info' href='#SYN_REPLY'>SYN_REPLY<span> (</span><span class='info'>SYN_REPLY</span><span>)</span></a>, <a class='info' href='#HEADERS'>HEADERS<span> (</span><span class='info'>HEADERS</span><span>)</span></a> or a <a class='info' href='#DataFrames'>DATA<span> (</span><span class='info'>Data frames</span><span>)</span></a> frame. Once the FLAG_FIN has been sent, the stream is considered to be half-closed.
</p>
<a name="StreamHalfClose"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3.6"></a><h3>2.3.6.
Stream half-close</h3>
<p>When one side of the stream sends a frame with the FLAG_FIN flag set, the stream is half-closed from that endpoint. The sender of the FLAG_FIN MUST NOT send further frames on that stream. When both sides have half-closed, the stream is closed.
</p>
<p>If an endpoint receives a data frame after the stream is half-closed from the sender (e.g. the endpoint has already received a prior frame for the stream with the FIN flag set), it MUST send a RST_STREAM to the sender with the status STREAM_ALREADY_CLOSED.
</p>
<a name="StreamClose"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.3.7"></a><h3>2.3.7.
Stream close</h3>
<p>There are 3 ways that streams can be terminated:
</p>
<blockquote class="text">
<p>Normal termination: Normal stream termination occurs when both sender and recipient have half-closed the stream by sending a FLAG_FIN.
</p>
<p>Abrupt termination: Either the client or server can send a RST_STREAM control frame at any time. A RST_STREAM contains an error code to indicate the reason for failure. When a RST_STREAM is sent from the stream originator, it indicates a failure to complete the stream and that no further data will be sent on the stream. When a RST_STREAM is sent from the stream recipient, the sender, upon receipt, should stop sending any data on the stream. The stream recipient should be aware that there is a race between data already in transit from the sender and the time the RST_STREAM is received. See <a class='info' href='#StreamErrorHandler'>Stream Error Handling<span> (</span><span class='info'>Stream Error Handling</span><span>)</span></a>
</p>
<p>TCP connection teardown: If the TCP connection is torn down while un-closed streams exist, then the endpoint must assume that the stream was abnormally interrupted and may be incomplete.
</p>
</blockquote><p>
</p>
<p>If an endpoint receives a data frame after the stream is closed, it must send a RST_STREAM to the sender with the status PROTOCOL_ERROR.
</p>
<a name="anchor10"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.4"></a><h3>2.4.
Error Handling</h3>
<p>The SPDY framing layer has only two types of errors, and they are always handled consistently. Any reference in this specification to "issue a session error" refers to <a class='info' href='#SessionErrorHandler'>Section 2.4.1<span> (</span><span class='info'>Session Error Handling</span><span>)</span></a>. Any reference to "issue a stream error" refers to <a class='info' href='#StreamErrorHandler'>Section 2.4.2<span> (</span><span class='info'>Stream Error Handling</span><span>)</span></a>.
</p>
<a name="SessionErrorHandler"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.4.1"></a><h3>2.4.1.
Session Error Handling</h3>
<p>A session error is any error which prevents further processing of the framing layer or which corrupts the session compression state. When a session error occurs, the endpoint encountering the error MAY send a <a class='info' href='#SETTINGS'>SETTINGS<span> (</span><span class='info'>SETTINGS</span><span>)</span></a> frame. Whether or not a <a class='info' href='#SETTINGS'>SETTINGS<span> (</span><span class='info'>SETTINGS</span><span>)</span></a> frame is sent, the endpoint encountering the error MUST send a <a class='info' href='#GOAWAY'>GOAWAY<span> (</span><span class='info'>GOAWAY</span><span>)</span></a> frame with the stream id of most recently received stream from the remote endpoint, and the error code for why the session is terminating. After sending the GOAWAY frame, the endpoint MUST close the TCP connection.
</p>
<p>Note that the session compression state is dependent upon both endpoints always processing all compressed data. If an endpoint partially processes a frame containing compressed data without updating compression state properly, future control frames which use compression will be always be errored. Implementations SHOULD always try to process compressed data so that errors which could be handled as stream errors do not become session errors.
</p>
<p>Note that because this GOAWAY is sent during a session error case, it is possible that the GOAWAY will not be reliably received by the receiving endpoint. It is a best-effort attempt to communicate with the remote about why the session is going down.
</p>
<a name="StreamErrorHandler"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.4.2"></a><h3>2.4.2.
Stream Error Handling</h3>
<p>A stream error is an error related to a specific stream-id which does not affect processing of other streams at the framing layer. Upon a stream error, the endpoint MUST send a <a class='info' href='#RST_STREAM'>RST_STREAM<span> (</span><span class='info'>RST_STREAM</span><span>)</span></a> frame which contains the stream id of the stream where the error occurred and the error status which caused the error. After sending the RST_STREAM, the stream is closed to the sending endpoint. After sending the RST_STREAM, if the sender receives any frames other than a RST_STREAM for that stream id, it will result in sending additional RST_STREAM frames. An endpoint MUST NOT send a RST_STREAM in response to an RST_STREAM, as doing so would lead to RST_STREAM loops. Sending a RST_STREAM does not cause the SPDY session to be closed.
</p>
<p>If an endpoint has multiple RST_STREAM frames to send in succession for the same stream-id and the same error code, it MAY coalesce them into a single RST_STREAM frame. (This can happen if a stream is closed, but the remote sends multiple data frames. There is no reason to send a RST_STREAM for each frame in succession).
</p>
<a name="anchor11"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.5"></a><h3>2.5.
Data flow</h3>
<p>Because TCP provides a single stream of data on which SPDY multiplexes multiple logical streams, clients and servers must intelligently interleave data messages for concurrent sessions.
</p>
<a name="ControlFrameTypes"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.6"></a><h3>2.6.
Control frame types</h3>
<table class="full" align="left" border="0" cellpadding="2" cellspacing="2">
<col align="center"><col align="center">
<tr><th align="center">Type-field value</th><th align="center">Control Frame-type</th></tr>
<tr>
<td align="center"> 0x1</td>
<td align="center"> <a class='info' href='#SYN_STREAM'>SYN_STREAM<span> (</span><span class='info'>SYN_STREAM</span><span>)</span></a></td>
</tr>
<tr>
<td align="center"> 0x2</td>
<td align="center"> <a class='info' href='#SYN_REPLY'>SYN_REPLY<span> (</span><span class='info'>SYN_REPLY</span><span>)</span></a></td>
</tr>
<tr>
<td align="center"> 0x3</td>
<td align="center"> <a class='info' href='#RST_STREAM'>RST_STREAM<span> (</span><span class='info'>RST_STREAM</span><span>)</span></a></td>
</tr>
<tr>
<td align="center"> 0x4</td>
<td align="center"> <a class='info' href='#SETTINGS'>SETTINGS<span> (</span><span class='info'>SETTINGS</span><span>)</span></a></td>
</tr>
<tr>
<td align="center"> 0x6</td>
<td align="center"> <a class='info' href='#PING'>PING<span> (</span><span class='info'>PING</span><span>)</span></a></td>
</tr>
<tr>
<td align="center"> 0x7</td>
<td align="center"> <a class='info' href='#GOAWAY'>GOAWAY<span> (</span><span class='info'>GOAWAY</span><span>)</span></a></td>
</tr>
<tr>
<td align="center"> 0x8</td>
<td align="center"> <a class='info' href='#HEADERS'>HEADERS<span> (</span><span class='info'>HEADERS</span><span>)</span></a></td>
</tr>
<tr>
<td align="center"> 0x9</td>
<td align="center"> <a class='info' href='#WINDOW_UPDATE'>WINDOW_UPDATE<span> (</span><span class='info'>WINDOW_UPDATE</span><span>)</span></a></td>
</tr>
<tr>
<td align="center"> 0xa</td>
<td align="center"> <a class='info' href='#CREDENTIAL'>CREDENTIAL<span> (</span><span class='info'>CREDENTIAL</span><span>)</span></a></td>
</tr>
<tr>
<td align="center"> 0xb</td>
<td align="center"> <a class='info' href='#PUSH_PROMISE'>PUSH_PROMISE<span> (</span><span class='info'>PUSH_PROMISE</span><span>)</span></a></td>
</tr>
</table>
<br clear="all" />
<p> Shared components of several control frames: <a class='info' href='#HeaderBlock'>Name/Value Header Block<span> (</span><span class='info'>Name/Value Header Block</span><span>)</span></a>
</p>
<a name="SYN_STREAM"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.6.1"></a><h3>2.6.1.
SYN_STREAM</h3>
<p>The SYN_STREAM control frame allows the sender to asynchronously create a stream between the endpoints. See <a class='info' href='#StreamCreation'>Stream Creation<span> (</span><span class='info'>Stream creation</span><span>)</span></a>
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
0 1 2 3 4 5 6 7
+--------+--------+--------+-|-------+--------+--------+--------+--------+
| Length(16) |Flags(8)|1| Stream Id(31) | 0x1 | ->
+--------+--------+--------+-|-------+--------+--------+--------+--------+
8 9,10,11..N
+---|-----+=========================+
|Pri|XXXXX| Name/Value Header Block |
+---|-----+=========================+
</pre></div>
<p>Flags: Flags related to this frame. Valid flags are:
</p>
<blockquote class="text">
<p>0x01 = FLAG_FIN - marks this frame as the last frame to be transmitted on this stream and puts the sender in the <a class='info' href='#StreamHalfClose'>half-closed<span> (</span><span class='info'>Stream half-close</span><span>)</span></a> state.
</p>
</blockquote><p>
</p>
<p>Length: The length is the number of bytes which follow the length field in the frame. For SYN_STREAM frames, this is 6 bytes plus the length of the Name/Value Header Block.
</p>
<p>Stream-ID: The 31-bit identifier for this stream. This stream-id will be used in frames which are part of this stream.
</p>
<p>Associated-To-Stream-ID: The 31-bit identifier for a stream which this stream is associated to. If this stream is independent of all other streams, it should be 0.
</p>
<p>Priority: A 3-bit <a class='info' href='#StreamPriority'>priority<span> (</span><span class='info'>Stream priority</span><span>)</span></a> field.
</p>
<p>Unused: 5 bits of unused space, reserved for future use.
</p>
<p>Name/Value Header Block: A set of name/value pairs carried as part of the SYN_STREAM. <a class='info' href='#HeaderBlock'>see Name/Value Header Block<span> (</span><span class='info'>Name/Value Header Block</span><span>)</span></a>.
</p>
<p>If an endpoint receives a SYN_STREAM which is larger than the implementation supports, it MAY send a RST_STREAM with error code FRAME_TOO_LARGE. All implementations MUST support the minimum size limits defined in <a class='info' href='#ControlFrames'>the Control Frames section<span> (</span><span class='info'>Control frames</span><span>)</span></a>.
</p>
<a name="SYN_REPLY"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.6.2"></a><h3>2.6.2.
SYN_REPLY</h3>
<p>SYN_REPLY indicates the acceptance of a stream creation by the recipient of a SYN_STREAM frame.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
0 1 2 3 4 5 6 7
+--------+--------+--------+-|-------+--------+--------+--------+--------+
| Length(16) |Flags(8)|1| Stream Id(31) | 0x2 | ->
+--------+--------+--------+-|-------+--------+--------+--------+--------+
8,9,10..N
+=========================+
| Name/Value Header Block |
+=========================+
</pre></div>
<p>Flags: Flags related to this frame. Valid flags are:
</p>
<blockquote class="text">
<p>0x01 = FLAG_FIN - marks this frame as the last frame to be transmitted on this stream and puts the sender in the <a class='info' href='#StreamHalfClose'>half-closed<span> (</span><span class='info'>Stream half-close</span><span>)</span></a> state.
</p>
</blockquote><p>
</p>
<p>Length: The length is the number of bytes which follow the length field in the frame. For SYN_REPLY frames, this is 4 bytes plus the length of the compressed Name/Value block.
</p>
<p>Stream-ID: The 31-bit identifier for this stream.
</p>
<p>If an endpoint receives multiple SYN_REPLY frames for the same active stream ID, it MUST issue a <a class='info' href='#StreamErrorHandler'>stream error<span> (</span><span class='info'>Stream Error Handling</span><span>)</span></a> with the error code STREAM_IN_USE.
</p>
<p>Name/Value Header Block: A set of name/value pairs carried as part of the SYN_STREAM. <a class='info' href='#HeaderBlock'>see Name/Value Header Block<span> (</span><span class='info'>Name/Value Header Block</span><span>)</span></a>.
</p>
<p>If an endpoint receives a SYN_REPLY which is larger than the implementation supports, it MAY send a RST_STREAM with error code FRAME_TOO_LARGE. All implementations MUST support the minimum size limits defined in <a class='info' href='#ControlFrames'>the Control Frames section<span> (</span><span class='info'>Control frames</span><span>)</span></a>.
</p>
<a name="RST_STREAM"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.6.3"></a><h3>2.6.3.
RST_STREAM</h3>
<p>The RST_STREAM frame allows for abnormal termination of a stream. When sent by the creator of a stream, it indicates the creator wishes to cancel the stream. When sent by the recipient of a stream, it indicates an error or that the recipient did not want to accept the stream, so the stream should be closed.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
0 1 2 3 4 5 6 7
+--------+--------+--------+-|-------+--------+--------+--------+--------+
| Length(16) |Flags(8)|1| Stream Id(31) | 0x3 | ->
+--------+--------+--------+-|-------+--------+--------+--------+--------+
8 9 10 11
+--------+--------+--------+--------+
| Status-Code(32) |
+--------+--------+--------+--------+
</pre></div>
<p>Flags: Flags related to this frame. RST_STREAM does not define any flags. This value must be 0.
</p>
<p>Length: An unsigned 16-bit value representing the number of bytes after the length field. For RST_STREAM control frames, this value is always 8.
</p>
<p>Stream-ID: The 31-bit identifier for this stream.
</p>
<p>Status code: (32 bits) An indicator for why the stream is being terminated.The following status codes are defined:
</p>
<blockquote class="text">
<p>1 - PROTOCOL_ERROR. This is a generic error, and should only be used if a more specific error is not available.
</p>
<p>2 - INVALID_STREAM. This is returned when a frame is received for a stream which is not active.
</p>
<p>3 - REFUSED_STREAM. Indicates that the stream was refused before any processing has been done on the stream.
</p>
<p>4 - UNSUPPORTED_VERSION. Indicates that the recipient of a stream does not support the SPDY version requested.
</p>
<p>5 - CANCEL. Used by the creator of a stream to indicate that the stream is no longer needed.
</p>
<p>6 - INTERNAL_ERROR. This is a generic error which can be used when the implementation has internally failed, not due to anything in the protocol.
</p>
<p>7 - FLOW_CONTROL_ERROR. The endpoint detected that its peer violated the flow control protocol.
</p>
<p>8 - STREAM_IN_USE. The endpoint received a SYN_REPLY for a stream already open.
</p>
<p>9 - STREAM_ALREADY_CLOSED. The endpoint received a data or SYN_REPLY frame for a stream which is half closed.
</p>
<p>10 - INVALID_CREDENTIALS. The server received a request for a resource whose origin does not have valid credentials in the client certificate vector.
</p>
<p>11 - FRAME_TOO_LARGE. The endpoint received a frame which this implementation could not support. If FRAME_TOO_LARGE is sent for a SYN_STREAM, HEADERS, or SYN_REPLY frame without fully processing the compressed portion of those frames, then the compression state will be out-of-sync with the other endpoint. In this case, senders of FRAME_TOO_LARGE MUST close the session.
</p>
<p>Note: 0 is not a valid status code for a RST_STREAM.
</p>
</blockquote><p>
</p>
<p>After receiving a RST_STREAM on a stream, the recipient must not send additional frames for that stream, and the stream moves into the closed state.
</p>
<a name="SETTINGS"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.6.4"></a><h3>2.6.4.
SETTINGS</h3>
<p>A SETTINGS frame contains a set of id/value pairs for communicating configuration data about how the two endpoints may communicate. SETTINGS frames can be sent at any time by either endpoint, are optionally sent, and are fully asynchronous. When the server is the sender, the sender can request that configuration data be persisted by the client across SPDY sessions and returned to the server in future communications.
</p>
<p>Persistence of SETTINGS ID/Value pairs is done on a per origin/IP pair (the "origin" is the set of scheme, host, and port from the URI. See <a class='info' href='#RFC6454'>[RFC6454]<span> (</span><span class='info'>Barth, A., “The Web Origin Concept,” December 2011.</span><span>)</span></a>). That is, when a client connects to a server, and the server persists settings within the client, the client SHOULD return the persisted settings on future connections to the same origin AND IP address and TCP port. Clients MUST NOT request servers to use the persistence features of the SETTINGS frames, and servers MUST ignore persistence related flags sent by a client.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
0 1 2 3 4 5 6 7
+--------+--------+--------+-|-------+--------+--------+--------+--------+
| Length(16) |Flags(8)|1| Number-of-Entries(31) | 0x4 | ->
+--------+--------+--------+-|-------+--------+--------+--------+--------+
8..n
+================+
| ID/Value-Pairs |
+================+
</pre></div>
<p>Control bit: The control bit is always 1 for this message.
</p>
<p>Type: The message type for a SETTINGS message is 4.
</p>
<p>Flags: FLAG_SETTINGS_CLEAR_SETTINGS (0x1): When set, the client should clear any previously persisted SETTINGS ID/Value pairs. If this frame contains ID/Value pairs with the FLAG_SETTINGS_PERSIST_VALUE set, then the client will first clear its existing, persisted settings, and then persist the values with the flag set which are contained within this frame. Because persistence is only implemented on the client, this flag can only be used when the sender is the server.
</p>
<p>Length: An unsigned 16-bit value representing the number of bytes after the length field. The total size of a SETTINGS frame is 8 bytes + length.
</p>
<p>Number of entries: A 32-bit value representing the number of ID/value pairs in this message.
</p>
<p>Each ID/value pair is as follows:
</p>
<div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
0 1 2 3 4 5 6 7
+--------+--------+--------+--------+--------+--------+--------+--------+
|Flags(8)| ID(24) | Value(32) |
+--------+--------+--------+--------+--------+--------+--------+--------+
</pre></div><p>
</p>
<p>Flags: An 8 bit value. Defined Flags:
</p>
<blockquote class="text">
<p>FLAG_SETTINGS_PERSIST_VALUE (0x1): When set, the sender of this SETTINGS frame is requesting that the recipient persist the ID/Value and return it in future SETTINGS frames sent from the sender to this recipient. Because persistence is only implemented on the client, this flag is only sent by the server.
</p>
<p>FLAG_SETTINGS_PERSISTED (0x2): When set, the sender is notifying the recipient that this ID/Value pair was previously sent to the sender by the recipient with the FLAG_SETTINGS_PERSIST_VALUE, and the sender is returning it. Because persistence is only implemented on the client, this flag is only sent by the client.
</p>
</blockquote><p>
</p>
<p>ID: 24-bits in network byte order. Defined IDs:
</p>
<blockquote class="text">
<p>1 - SETTINGS_UPLOAD_BANDWIDTH allows the sender to send its expected upload bandwidth on this channel. This number is an estimate. The value should be the integral number of kilobytes per second that the sender predicts as an expected maximum upload channel capacity.
</p>
<p>2 - SETTINGS_DOWNLOAD_BANDWIDTH allows the sender to send its expected download bandwidth on this channel. This number is an estimate. The value should be the integral number of kilobytes per second that the sender predicts as an expected maximum download channel capacity.
</p>
<p>3 - SETTINGS_ROUND_TRIP_TIME allows the sender to send its expected round-trip-time on this channel. The round trip time is defined as the minimum amount of time to send a control frame from this client to the remote and receive a response. The value is represented in milliseconds.
</p>
<p>4 - SETTINGS_MAX_CONCURRENT_STREAMS allows the sender to inform the remote endpoint the maximum number of concurrent streams which it will allow. By default there is no limit. For implementors it is recommended that this value be no smaller than 100.
</p>
<p>5 - SETTINGS_CURRENT_CWND allows the sender to inform the remote endpoint of the current TCP CWND value.
</p>
<p>6 - SETTINGS_DOWNLOAD_RETRANS_RATE allows the sender to inform the remote endpoint the retransmission rate (bytes retransmitted / total bytes transmitted).
</p>
<p>7 - SETTINGS_INITIAL_WINDOW_SIZE allows the sender to inform the remote endpoint the initial window size (in bytes) for new streams.
</p>
<p>8 - SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE allows the server to inform the client if the new size of the client certificate vector.
</p>
<p>9 - SETTINGS_SUPPORTING_SCHEMES allows the sender to inform the remote endpoint supporting overlayering protocol schemes. The corresponding value must be a 32-bit value, and which contains flags as follows:
</p>
<blockquote class="text">
<p>bit 0: http
</p>
<p>bit 1: https
</p>
<p>bit 2: ws
</p>
<p>bit 3: wss
</p>
</blockquote>
</blockquote><p>
</p>
<p>Value: A 32-bit value.
</p>
<p>The message is intentionally extensible for future information which may improve client-server communications. The sender does not need to send every type of ID/value. It must only send those for which it has accurate values to convey. When multiple ID/value pairs are sent, they should be sent in order of lowest id to highest id. A single SETTINGS frame MUST not contain multiple values for the same ID. If the recipient of a SETTINGS frame discovers multiple values for the same ID, it MUST ignore all values except the first one.
</p>
<p>A server may send multiple SETTINGS frames containing different ID/Value pairs. When the same ID/Value is sent twice, the most recent value overrides any previously sent values. If the server sends IDs 1, 2, and 3 with the FLAG_SETTINGS_PERSIST_VALUE in a first SETTINGS frame, and then sends IDs 4 and 5 with the FLAG_SETTINGS_PERSIST_VALUE, when the client returns the persisted state on its next SETTINGS frame, it SHOULD send all 5 settings (1, 2, 3, 4, and 5 in this example) to the server.
</p>
<a name="PING"></a><br /><hr />
<table summary="layout" cellpadding="0" cellspacing="2" class="TOCbug" align="right"><tr><td class="TOCbug"><a href="#toc"> TOC </a></td></tr></table>
<a name="rfc.section.2.6.5"></a><h3>2.6.5.
PING</h3>
<p>The PING control frame is a mechanism for measuring a minimal round-trip time from the sender. It can be sent from the client or the server. Recipients of a PING frame should send an identical frame to the sender as soon as possible (if there is other pending data waiting to be sent, PING should take highest priority). Each ping sent by a sender should use a unique ID.
</p><div style='display: table; width: 0; margin-left: 3em; margin-right: auto'><pre>
0 1 2 3 4 5 6 7
+--------+--------+--------+-|-------+--------+--------+--------+--------+
| Length(16) |XXXXXXXX|1| ID(31) | 0x6 | ->
+--------+--------+--------+-|-------+--------+--------+--------+--------+
</pre></div>
<p>Control bit: The control bit is always 1 for this message.
</p>
<p>Type: The message type for a PING message is 6.
</p>