draft-ietf-hybi-permessage-compression-04.txt   draft-ietf-hybi-permessage-compression-05.txt 
HyBi Working Group T. Yoshino HyBi Working Group T. Yoshino
Internet-Draft Google, Inc. Internet-Draft Google, Inc.
Intended status: Standards Track October 19, 2012 Intended status: Standards Track January 24, 2013
Expires: April 22, 2013 Expires: July 28, 2013
WebSocket Per-message Compression WebSocket Per-message Compression
draft-ietf-hybi-permessage-compression-04 draft-ietf-hybi-permessage-compression-05
Abstract Abstract
This specification defines a WebSocket extension that adds This document specifies a framework for creating WebSocket extensions
compression functionality to the WebSocket Protocol. It compresses that add compression functionality to the WebSocket Protocol.
the payload of non-control WebSocket messages using specified Extensions based on this framework compress the payload of non-
compression algorithm. One reserved bit RSV1 in the WebSocket frame control WebSocket messages using a specified compression algorithm.
header is allocated to control application of compression for each One reserved bit RSV1 in the WebSocket frame header is allocated to
message. This specification provides one compression method control application of compression for each message. This document
available for the extension using DEFLATE. also specifies one specific compression extension using DEFLATE.
Please send feedback to the hybi@ietf.org mailing list. Please send feedback to the hybi@ietf.org mailing list.
Status of this Memo Status of this Memo
This Internet-Draft is submitted to IETF in full conformance with the This Internet-Draft is submitted to IETF in full conformance with the
provisions of BCP 78 and BCP 79. provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current. Drafts is at http://datatracker.ietf.org/drafts/current.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on April 22, 2013. This Internet-Draft will expire on July 28, 2013.
Copyright Notice Copyright Notice
Copyright (c) 2012 IETF Trust and the persons identified as the Copyright (c) 2013 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Conformance Requirements . . . . . . . . . . . . . . . . . . . 4 2. Conformance Requirements . . . . . . . . . . . . . . . . . . . 4
3. Extension Negotiation . . . . . . . . . . . . . . . . . . . . 5 3. Extension Negotiation . . . . . . . . . . . . . . . . . . . . 5
3.1. Negotiation Example . . . . . . . . . . . . . . . . . . . 6 3.1. Negotiation Example . . . . . . . . . . . . . . . . . . . 5
4. Framing . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4. Framing . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.1. Sending . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.1. Sending . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.2. Receiving . . . . . . . . . . . . . . . . . . . . . . . . 7 4.2. Receiving . . . . . . . . . . . . . . . . . . . . . . . . 7
5. DEFLATE method . . . . . . . . . . . . . . . . . . . . . . . . 8 5. permessage-deflate extension . . . . . . . . . . . . . . . . . 8
5.1. Method Parameters . . . . . . . . . . . . . . . . . . . . 8 5.1. Method Parameters . . . . . . . . . . . . . . . . . . . . 8
5.1.1. Disallow compression context takeover . . . . . . . . 8 5.1.1. Disallow compression context takeover . . . . . . . . 8
5.1.2. Limit maximum LZ77 sliding window size . . . . . . . . 9 5.1.2. Limit maximum LZ77 sliding window size . . . . . . . . 9
5.1.3. Example . . . . . . . . . . . . . . . . . . . . . . . 9 5.1.3. Example . . . . . . . . . . . . . . . . . . . . . . . 10
5.2. Application Data Transformation . . . . . . . . . . . . . 10 5.2. Application Data Transformation . . . . . . . . . . . . . 10
5.2.1. Compression . . . . . . . . . . . . . . . . . . . . . 10 5.2.1. Compression . . . . . . . . . . . . . . . . . . . . . 10
5.2.2. Decompression . . . . . . . . . . . . . . . . . . . . 11 5.2.2. Decompression . . . . . . . . . . . . . . . . . . . . 11
5.2.3. Examples . . . . . . . . . . . . . . . . . . . . . . . 12 5.2.3. Examples . . . . . . . . . . . . . . . . . . . . . . . 12
5.3. Intermediaries . . . . . . . . . . . . . . . . . . . . . . 14 5.3. Intermediaries . . . . . . . . . . . . . . . . . . . . . . 14
5.4. Implementation Notes . . . . . . . . . . . . . . . . . . . 15 5.4. Implementation Notes . . . . . . . . . . . . . . . . . . . 15
6. Security Considerations . . . . . . . . . . . . . . . . . . . 16 6. Security Considerations . . . . . . . . . . . . . . . . . . . 16
7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 17 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 17
7.1. Registration of the "permessage-compress" WebSocket 7.1. Registration of the "permessage-deflate" WebSocket
Extension Name . . . . . . . . . . . . . . . . . . . . . . 17 Extension Name . . . . . . . . . . . . . . . . . . . . . . 17
7.2. Registration of the "Per-message Compressed" WebSocket 7.2. Registration of the "Per-message Compressed" WebSocket
Framing Header Bit . . . . . . . . . . . . . . . . . . . . 17 Framing Header Bit . . . . . . . . . . . . . . . . . . . . 17
7.3. WebSocket Per-message Compression Method Name Registry . . 18 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 18
8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 19 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 19
9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 20 9.1. Normative References . . . . . . . . . . . . . . . . . . . 19
9.1. Normative References . . . . . . . . . . . . . . . . . . . 20 9.2. Informative References . . . . . . . . . . . . . . . . . . 19
9.2. Informative References . . . . . . . . . . . . . . . . . . 20 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 20
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 21
1. Introduction 1. Introduction
_This section is non-normative._ _This section is non-normative._
As well as other communication protocols, the WebSocket Protocol As well as other communication protocols, the WebSocket Protocol
[RFC6455] can benefit from compression technology. This [RFC6455] can benefit from compression technology. This document
specification defines a WebSocket extension that applies a specifies a framework for creating WebSocket extensions that apply a
compression algorithm to octets exchanged over the WebSocket Protocol compression algorithm to octets exchanged over the WebSocket Protocol
using its extension framework. This extension negotiates what using its extension framework. Extensions based on this framework
compression method to use on opening handshake, and then compresses negotiate compression parameters during the opening handshake, and
the octets in non-control messages using the method. We can apply then compress the octets in non-control messages. Extensions for
this extension to various compression algorithms by specifying how to various compression algorithms can be specified by describing how to
negotiate parameters and transform payload. A client may offer negotiate parameters and transform data in payloads. A client may
multiple compression methods on opening handshake, and then the offer multiple compression algorithms during the opening handshake by
server chooses one from them. This extension uses the RSV1 bit of listing multiple compression extensions. The server may choose
the WebSocket frame header to indicate whether the message is preferred one from them. Extensions based on this framework share
compressed or not, so that we can choose to skip messages with the RSV1 bit of the WebSocket frame header to indicate whether the
incompressible contents without applying extra compression. message is compressed or not, so that we can choose to skip messages
with incompressible contents avoiding extra compression.
This specification provides one specific compression method "deflate" This document also specifies one specific extension "permessage-
which is based on DEFLATE [RFC1951] for this extension. We chose deflate" which is based on DEFLATE [RFC1951] algorithm. We chose
DEFLATE since it's widely available as library on various platforms DEFLATE since it's widely available as library on various platforms
and the overhead it adds for each chunk is small. To align the end and the overhead it adds for each chunk is small. To align the end
of compressed data to octet boundary, this method uses the algorithm of compressed data to octet boundary, this extension uses the
described in the Section 2.1 of the PPP Deflate Protocol [RFC1979]. algorithm described in the Section 2.1 of the PPP Deflate Protocol
Endpoints can take over the LZ77 sliding window [LZ77] used to build [RFC1979]. Endpoints can take over the LZ77 sliding window [LZ77]
previous messages to get better compression ratio. For resource- used to build previous messages to get better compression ratio. For
limited devices, method parameters to limit the usage of memory for resource-limited devices, this extension provides parameters to limit
compression context are provided. memory usage for compression context.
The simplest "Sec-WebSocket-Extensions" header in the client's The simplest "Sec-WebSocket-Extensions" header in the client's
opening handshake to request DEFLATE based per-message compression is opening handshake to request permessage-deflate is the following:
the following:
Sec-WebSocket-Extensions: permessage-compress; method=deflate Sec-WebSocket-Extensions: permessage-deflate
The simplest header from the server to accept this extension is the The simplest header from the server to accept this extension is the
same. same.
2. Conformance Requirements 2. Conformance Requirements
Everything in this specification except for sections explicitly Everything in this specification except for sections explicitly
marked non-normative is normative. marked non-normative is normative.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [RFC2119]. document are to be interpreted as described in [RFC2119].
3. Extension Negotiation 3. Extension Negotiation
The registered extension token for this extension is Extension names and negotiation methods are specified individually
"permessage-compress". for each compression algorithm. There is no additional rule for
extension naming. Extensions build based on this framework are
To request use of the Per-message Compression Extension, a client collectively called "Per-message Compression Extensions".
MUST include an element with the "permessage-compress" extension
token as its extension identifier in the "Sec-WebSocket-Extensions"
header in its opening handshake. The element MUST contain exactly
one extension parameter named "method". The value of the "method"
extension parameter is a list of compression method descriptions,
ordered by preference. Each compression method description has a
method name and optional method parameters. The grammar of the list
is "requested-method-list" defined in the following ABNFs.
requested-method-list = 1#method-desc
method-desc = method-name *(";" method-param)
method-name = token
method-param = token ["=" (token | quoted-string)]
The list MAY contain multiple method descriptions with the same
method name.
To accept use of the Per-message Compression Extension, a server MUST
choose one compression method description to accept from ones listed
by the client, and include an element with the "permessage-compress"
extension token in the "Sec-WebSocket-Extensions" header in its
opening handshake. The chosen description is called "accepted
request". The element in the server's "Sec-WebSocket-Extensions"
MUST contain exactly one extension parameter named "method". The
value of the "method" extension parameter MUST be a compression
method description. This description is called "method agreement".
The method name in the "method agreement" MUST be one of the accepted
request. The "method agreement" MUST be derived from the "accepted
request" and the server's capability. If the server doesn't support
any of the descriptions listed by the client, the server MUST reject
use of the Per-message Compression Extension. Its grammar is
"method-agreement" defined in the following ABNF.
method-agreement = method-desc To request use of a Per-message Compression Extension, a client MUST
include an element with its extension token in the
"Sec-WebSocket-Extensions" header in its opening handshake. The
element contains extension parameters as specified by the
specification of the extension. A client MAY list multiple Per-
message Compression Extensions with the same name to offer use of the
same algorithm with different configurations.
The value of the "method" parameter MUST be quoted by using To accept use of a Per-message Compression Extension, a server MUST
"quoted-string" syntax if it doesn't conform to token syntax. include an element with its extension token in the
"Sec-WebSocket-Extensions" header in its opening handshake. The
element contains extension parameters as specified by the
specification of the extension. The parameters MUST be derived from
the parameters sent by the client and the server's capability. To
reject use of a Per-message Compression Extension, a server MUST
simply ignore the element in the "Sec-WebSocket-Extensions" header in
the client's opening handshake.
If a client doesn't support the method and its configuration If a client doesn't support the extension and its parameters replied
specified by the "method agreement", the client MUST _Fail the from the server, the client MUST _Fail the WebSocket Connection_.
WebSocket Connection_. Otherwise, both endpoints MUST use the Otherwise, once _the WebSocket Connection is established_, both
algorithm described in Section 4 to exchange messages. endpoints MUST use the algorithm described in Section 4 to exchange
messages.
3.1. Negotiation Example 3.1. Negotiation Example
_This section is non-normative._ _This section is non-normative._
These are "Sec-WebSocket-Extensions" header value examples that These are "Sec-WebSocket-Extensions" header value examples that
negotiate the Per-message Compression Extension. negotiate the Per-message Compression Extension. permessage-foo and
permessage-bar in the examples are extension names of Per-message
Compression Extensions for hypothetical compression algorithm foo and
bar.
o Request foo method. Since foo matches token syntax, it doesn't o Request foo.
need to be quoted.
permessage-compress; method=foo permessage-foo
o Request foo method with a parameter x with 10 as its value. Since o Request foo with a parameter x with 10 as its value.
the method parameter value contains a semicolon, it doesn't match
token syntax. Quotation is needed.
permessage-compress; method="foo; x=10" permessage-foo; x=10
o Request foo method and bar method. Since the method parameter o Request foo with a parameter z with "Hello World" (quotation for
value contains a comma, it doesn't match token syntax. Quotation clarification) as its value. Since "Hello World" contains a
is needed. space, it needs to be quoted.
permessage-compress; method="foo, bar" permessage-foo; z="Hello World"
o Request foo method with a feature x but also allowing fallback to o Request foo and bar.
one without the feature.
permessage-compress; method="foo; use_x, foo" permessage-foo, permessage-bar
o Request foo method with parameter x with "Hello World" (quotation o Request foo with a parameter use_y which enables a feature y as
for clarification) as its value and bar method. Since "Hello first choice, and also list one without the parameter as a
World" contains a space, it needs to be quoted. Since quoted fallback plan.
"Hello World" contains double quotations and a space, it needs to
be quoted again.
permessage-compress; method="foo; x=\"Hello World\", bar" permessage-foo; use_y, permessage-foo
4. Framing 4. Framing
This section describes how to apply the negotiated compression method This section describes how to apply the negotiated compression method
to the contents of WebSocket messages. to the contents of WebSocket messages.
This extension allocates the RSV1 bit of the WebSocket header and This document allocates the RSV1 bit of the WebSocket header for
names it the "Per-message Compressed" bit. Any extension requiring extensions based on this framework, and names it the "Per-message
the use of the RSV1 bit is incompatible with this extension. This Compressed" bit. Any other extension requiring the use of the RSV1
bit MAY be set only on the first fragment of a message. This bit bit is incompatible with these extensions. This bit MAY be set only
indicates whether the compression method is applied to the message or on the first fragment of a message. This bit indicates whether the
not. Messages with the "Per-message Compressed" bit set (on its compression method is applied to the message or not. Messages with
first fragment) are called "compressed messages". They have the "Per-message Compressed" bit set (on its first fragment) are
compressed data in their payload. Messages with the bit unset are called "compressed messages". They have compressed data in their
called "uncompressed messages". They have uncompressed data in their payload. Messages with the bit unset are called "uncompressed
payload. messages". They have uncompressed data in their payload.
This extension MUST NOT be used after any extension for which frame Per-message Compression Extensions MUST NOT be used after any
boundary needs to be preserved. This extension MUST NOT be used extension for which frame boundary needs to be preserved. Per-
after any extension that uses "Extension data" field or any of the message Compression Extensions MUST NOT be used after any extension
reserved bits on the WebSocket header as per-frame attribute. that uses "Extension data" field or any of the reserved bits on the
WebSocket header as per-frame attribute.
This extension operates only on data frames. Per-message Compression Extensions operates only on data frames.
4.1. Sending 4.1. Sending
To send a compressed message, an endpoint MUST use the following To send a compressed message, an endpoint MUST use the following
algorithm. algorithm.
1. Compress the payload of the message using the compression method. 1. Compress the payload of the message using the compression method.
2. Build frame(s) for the message by putting the resulting octets 2. Build frame(s) for the message by putting the resulting octets
instead of the original octets. instead of the original octets.
skipping to change at page 8, line 5 skipping to change at page 8, line 5
the compression method. the compression method.
4.2. Receiving 4.2. Receiving
To receive a compressed message, an endpoint MUST decompress its To receive a compressed message, an endpoint MUST decompress its
payload. payload.
An endpoint MUST receive an uncompressed message as-is without An endpoint MUST receive an uncompressed message as-is without
decompression. decompression.
5. DEFLATE method 5. permessage-deflate extension
This section defines a method named "deflate" for this extension that This section specifies a specific extension called
compresses the payload of messages using DEFLATE [RFC1951] and byte "permessage-deflate" that compresses the payload of messages using
boundary alignment method introduced in [RFC1979]. DEFLATE [RFC1951] and byte boundary alignment method introduced in
[RFC1979].
The registered extension token for this extension is
"permessage-deflate".
5.1. Method Parameters 5.1. Method Parameters
The following 4 method parameters are defined for "deflate" method in The following 4 parameters are defined in the following subsections
the following subsections. for this extension.
o "s2c_no_context_takeover" o "s2c_no_context_takeover"
o "c2s_no_context_takeover" o "c2s_no_context_takeover"
o "s2c_max_window_bits" o "s2c_max_window_bits"
o "c2s_max_window_bits" o "c2s_max_window_bits"
A server MUST ignore "deflate" method descriptions that: A server MUST ignore a "permessage-deflate" extension entry if any of
the following is true:
o have any method parameter unknown to the server o It has any parameter unknown to the server
o have any method parameter with an invalid value o It has any parameter with an invalid value
o is not supported by the server o It is not supported by the server
A client MUST _Fail the WebSocket Connection_ if the "method A client MUST _Fail the WebSocket Connection_ if any of the following
agreement": is true about the received "permessage-deflate" extension entry:
o has any method parameter unknown to the client o It has any parameter unknown to the client
o has any method parameter with an invalid value o It has any parameter with an invalid value
o is not supported by the client o It is not supported by the client
5.1.1. Disallow compression context takeover 5.1.1. Disallow compression context takeover
A client MAY attach the "s2c_no_context_takeover" method parameter to A client MAY attach the "s2c_no_context_takeover" parameter to
disallow the server to take over the LZ77 sliding window used to disallow the server to take over the LZ77 sliding window used to
build previous messages. Servers SHOULD be able to accept the build previous messages. Servers SHOULD be able to accept the
"s2c_no_context_takeover" method parameter. If the "accepted "s2c_no_context_takeover" parameter. To accept a request with this
request" has this method parameter, the server: parameter, a server:
o MUST attach this parameter to its response
o MUST reset its LZ77 sliding window for sending to empty for each o MUST reset its LZ77 sliding window for sending to empty for each
message message
o MUST attach this method parameter to its "method agreement" A server MAY attach the "c2s_no_context_takeover" parameter to
A server MAY attach the "c2s_no_context_takeover" method parameter to
disallow the client to take over the LZ77 sliding window used to disallow the client to take over the LZ77 sliding window used to
build previous messages. Clients SHOULD be able to accept the build previous messages. Clients SHOULD be able to accept the
"c2s_no_context_takeover" method parameter. A client that received "c2s_no_context_takeover" parameter. A client that received this
this parameter MUST reset its LZ77 sliding window for sending to parameter MUST reset its LZ77 sliding window for sending to empty for
empty for each message. each message.
These parameters have no value. These parameters have no value.
5.1.2. Limit maximum LZ77 sliding window size 5.1.2. Limit maximum LZ77 sliding window size
A client MAY attach the "s2c_max_window_bits" method parameter to A client MAY attach the "s2c_max_window_bits" parameter to limit the
limit the LZ77 sliding window size that the server uses to build LZ77 sliding window size that the server uses to build messages.
messages. This parameter MUST have a decimal integer value in the This parameter MUST have a decimal integer value in the range between
range between 8 to 15 indicating the base-2 logarithm of the LZ77 8 to 15 indicating the base-2 logarithm of the LZ77 sliding window
sliding window size. The ABNF [RFC5234] for the value of this size. The ABNF [RFC5234] for the value of this parameter is 1*DIGIT.
parameter is 1*DIGIT. Servers MAY be able to accept the Servers MAY be able to accept the "s2c_max_window_bits" parameter.
"s2c_max_window_bits" method parameter. If the "accepted request" To accept a request with this parameter, the server:
has this method parameter, the server:
o MUST attach this method parameter with the same value as one of o MUST attach this parameter with the same value as one of the
the "accepted request" to its "method agreement" "accepted request" to its response
o MUST NOT use LZ77 sliding window size greater than the size o MUST NOT use LZ77 sliding window size greater than the size
specified by this parameter to build messages specified by this parameter to build messages
A client MAY attach the "c2s_max_window_bits" method parameter if the A client MAY attach the "c2s_max_window_bits" parameter if the client
client can adjust LZ77 sliding window size based on the can adjust LZ77 sliding window size based on the
"c2s_max_window_bits" sent by the server. This parameter has no "c2s_max_window_bits" sent by the server. This parameter has no
value. value.
If the "accepted request" has the "c2s_max_window_bits" method If the received request has the "c2s_max_window_bits" parameter, the
parameter, the server MAY attach the "c2s_max_window_bits" method server MAY respond to the request with the "c2s_max_window_bits"
parameter to limit the LZ77 sliding window size that the client uses parameter to limit the LZ77 sliding window size that the client uses
to build messages. Otherwise, the server MUST NOT attach the to build messages. Otherwise, the server MUST NOT accept the request
parameter. This parameter sent by the server MUST have a decimal with a response with the parameter. This parameter sent by the
integer value in the range between 8 to 15 indicating the base-2 server MUST have a decimal integer value in the range between 8 to 15
logarithm of the LZ77 sliding window size. The ABNF for the value of indicating the base-2 logarithm of the LZ77 sliding window size. The
this parameter is 1*DIGIT. A client that received this parameter ABNF for the value of this parameter is 1*DIGIT. A client that
MUST NOT use LZ77 sliding window size greater than the size specified received this parameter MUST NOT use LZ77 sliding window size greater
by this parameter to build messages. than the size specified by this parameter to build messages.
5.1.3. Example 5.1.3. Example
_This section is non-normative._ _This section is non-normative._
This example sent by a client is asking the server to use LZ77 This example sent by a client is asking the server to use LZ77
sliding window size of 1,024 bytes or less and declaring that the sliding window size of 1,024 bytes or less and declaring that the
client can accept the "c2s_max_window_bits" parameter. client can accept the "c2s_max_window_bits" parameter.
Sec-WebSocket-Extensions: permessage-compress; Sec-WebSocket-Extensions: permessage-deflate;
method="deflate; c2s_max_window_bits; c2s_max_window_bits;
s2c_max_window_bits=10" s2c_max_window_bits=10
This request might be rejected by the server because it doesn't This request might be rejected by the server because it doesn't
support the "s2c_max_window_bits" parameter. Since there's only one support the "s2c_max_window_bits" parameter. Since there's only one
method description listed in the header, the server need to give up compression extension listed in the header, the server need to give
use of the Per-message Compression Extension entirely. If reduction up use of the Per-message Compression Extension entirely. If
of LZ77 sliding window size by the server is mandatory for the reduction of LZ77 sliding window size by the server is mandatory for
client, this is fine. the client, this is fine.
The next example lists two configurations so that the server can The next example lists two configurations so that the server can
accept permessage-compress by picking one of the configurations it accept permessage-deflate by picking supported one from them.
supports.
Sec-WebSocket-Extensions: permessage-compress; Sec-WebSocket-Extensions:
method="deflate; s2c_max_window_bits=10, deflate" permessage-deflate; s2c_max_window_bits=10,
permessage-deflate
The server can choose to accept the second description by sending The server can choose to accept the second extension entry by sending
back this for example: back this for example:
Sec-WebSocket-Extensions: permessage-compress; Sec-WebSocket-Extensions: permessage-deflate
method=deflate
Since the "c2s_max_window_bits" parameter was not specified for both Since the "c2s_max_window_bits" parameter was not specified for both
of the method descriptions, the server cannot use the of the extensions, the server cannot use the "c2s_max_window_bits"
"c2s_max_window_bits" parameter. parameter.
5.2. Application Data Transformation 5.2. Application Data Transformation
5.2.1. Compression 5.2.1. Compression
An endpoint MUST use the following algorithm to compress a message. An endpoint MUST use the following algorithm to compress a message.
1. Compress all the octets of the payload of the message using 1. Compress all the octets of the payload of the message using
DEFLATE. DEFLATE.
skipping to change at page 11, line 21 skipping to change at page 11, line 25
o Both block with "BFINAL" set to 0 and 1 MAY be used. o Both block with "BFINAL" set to 0 and 1 MAY be used.
o When any block with "BFINAL" set to 1 doesn't end at byte o When any block with "BFINAL" set to 1 doesn't end at byte
boundary, minimal padding bits of 0 MUST be added to make it end boundary, minimal padding bits of 0 MUST be added to make it end
at byte boundary, and then the next block MUST start at the byte at byte boundary, and then the next block MUST start at the byte
boundary if any. boundary if any.
An endpoint MUST NOT use an LZ77 sliding window greater than 32,768 An endpoint MUST NOT use an LZ77 sliding window greater than 32,768
bytes to build messages to send. bytes to build messages to send.
If the "method agreement" has the "s2c_no_context_takeover" method If the server specified the "s2c_no_context_takeover" parameter, the
parameter, the server MUST reset its LZ77 sliding window for sending server MUST reset its LZ77 sliding window for sending to empty for
to empty for each message. Otherwise, the server MAY take over the each message. Otherwise, the server MAY take over the LZ77 sliding
LZ77 sliding window used to build the last compressed message. window used to build the last compressed message.
If the "method agreement" has the "c2s_no_context_takeover" method If the server specified the "c2s_no_context_takeover" parameter, the
parameter, the client MUST reset its LZ77 sliding window for sending client MUST reset its LZ77 sliding window for sending to empty for
to empty for each message. Otherwise, the client MAY take over the each message. Otherwise, the client MAY take over the LZ77 sliding
LZ77 sliding window used to build the last compressed message. window used to build the last compressed message.
If the "method agreement" has the "s2c_max_window_bits" method If the server specified the "s2c_max_window_bits" parameter and its
parameter and its value is w, the server MUST NOT use an LZ77 sliding value is w, the server MUST NOT use an LZ77 sliding window greater
window greater than w-th power of 2 bytes to build messages to send. than w-th power of 2 bytes to build messages to send.
If the "method agreement" has the "c2s_max_window_bits" method If the server specified the "c2s_max_window_bits" parameter and its
parameter and its value is w, the client MUST NOT use an LZ77 sliding value is w, the client MUST NOT use an LZ77 sliding window greater
window greater than w-th power of 2 bytes to build messages to send. than w-th power of 2 bytes to build messages to send.
5.2.2. Decompression 5.2.2. Decompression
An endpoint MUST use the following algorithm to decompress a message. An endpoint MUST use the following algorithm to decompress a message.
1. Append 4 octets of 0x00 0x00 0xff 0xff to the tail of the payload 1. Append 4 octets of 0x00 0x00 0xff 0xff to the tail of the payload
of the message. of the message.
2. Decompress the resulting octets using DEFLATE. 2. Decompress the resulting octets using DEFLATE.
If the "method agreement" has the "s2c_no_context_takeover" method If the server specified the "s2c_no_context_takeover" parameter, the
parameter, the client MAY reset its LZ77 sliding window for receiving client MAY reset its LZ77 sliding window for receiving to empty for
to empty for each message. Otherwise, the client MUST take over the each message. Otherwise, the client MUST take over the LZ77 sliding
LZ77 sliding window used to parse the last compressed message. window used to parse the last compressed message.
If the "method agreement" has the "c2s_no_context_takeover" method If the server specified the "c2s_no_context_takeover" parameter, the
parameter, the server MAY reset its LZ77 sliding window for receiving server MAY reset its LZ77 sliding window for receiving to empty for
to empty for each message. Otherwise, the server MUST take over the each message. Otherwise, the server MUST take over the LZ77 sliding
LZ77 sliding window used to parse the last compressed message. window used to parse the last compressed message.
If the "method agreement" has the "s2c_max_window_bits" method If the server specified the "s2c_max_window_bits" parameter and its
parameter and its value is w, the client MAY reduce the size of the value is w, the client MAY reduce the size of the LZ77 sliding window
LZ77 sliding window to decompress received messages down to the w-th to decompress received messages down to the w-th power of 2 bytes.
power of 2 bytes. Otherwise, the client MUST use a 32,768 byte LZ77 Otherwise, the client MUST use a 32,768 byte LZ77 sliding window to
sliding window to decompress received messages. decompress received messages.
If the "method agreement" has the "c2s_max_window_bits" method If the server specified the "c2s_max_window_bits" parameter and its
parameter and its value is w, the server MAY reduce the size of the value is w, the server MAY reduce the size of the LZ77 sliding window
LZ77 sliding window to decompress received messages down to the w-th to decompress received messages down to the w-th power of 2 bytes.
power of 2 bytes. Otherwise, the server MUST use a 32,768 byte LZ77 Otherwise, the server MUST use a 32,768 byte LZ77 sliding window to
sliding window to decompress received messages. decompress received messages.
5.2.3. Examples 5.2.3. Examples
_This section is non-normative._ _This section is non-normative._
This section introduces examples of how the DEFLATE method transforms This section introduces examples of how the permessage-deflate
messages. transforms messages.
5.2.3.1. A message compressed using 1 compressed block 5.2.3.1. A message compressed using 1 compressed block
Suppose that a text message "Hello" is sent using the DEFLATE method. Suppose that a text message "Hello" is sent. When 1 compressed block
When 1 compressed block (compressed with fixed Huffman code, "BFINAL" (compressed with fixed Huffman code, "BFINAL" is not set) is used,
is not set) is used, compressed data to be sent in payload is compressed data to be sent in payload is obtained as follows.
obtained as follows.
Compress "Hello" into 1 compressed block and flush it into a byte Compress "Hello" into 1 compressed block and flush it into a byte
array using an empty block with no compression: array using an empty block with no compression:
0xf2 0x48 0xcd 0xc9 0xc9 0x07 0x00 0x00 0x00 0xff 0xff 0xf2 0x48 0xcd 0xc9 0xc9 0x07 0x00 0x00 0x00 0xff 0xff
Strip 0x00 0x00 0xff 0xff from the tail: Strip 0x00 0x00 0xff 0xff from the tail:
0xf2 0x48 0xcd 0xc9 0xc9 0x07 0x00 0xf2 0x48 0xcd 0xc9 0xc9 0x07 0x00
skipping to change at page 17, line 7 skipping to change at page 17, line 7
To get sufficient compression ratio, LZ77 sliding window size of To get sufficient compression ratio, LZ77 sliding window size of
1,024 or more is recommended. 1,024 or more is recommended.
6. Security Considerations 6. Security Considerations
There are no security concerns for now. There are no security concerns for now.
7. IANA Considerations 7. IANA Considerations
7.1. Registration of the "permessage-compress" WebSocket Extension Name 7.1. Registration of the "permessage-deflate" WebSocket Extension Name
This section describes a WebSocket extension name registration in the This section describes a WebSocket extension name registration in the
WebSocket Extension Name Registry [RFC6455]. WebSocket Extension Name Registry [RFC6455].
Extension Identifier Extension Identifier
permessage-compress permessage-deflate
Extension Common Name Extension Common Name
WebSocket Per-message Compression WebSocket Per-message Deflate
Extension Definition Extension Definition
This document. This document.
Known Incompatible Extensions Known Incompatible Extensions
None None
The "permessage-compress" token is used in the The "permessage-deflate" token is used in the
"Sec-WebSocket-Extensions" header in the WebSocket opening handshake "Sec-WebSocket-Extensions" header in the WebSocket opening handshake
to negotiate use of the Per-message Compression Extension. to negotiate use of the permessage-deflate extension.
7.2. Registration of the "Per-message Compressed" WebSocket Framing 7.2. Registration of the "Per-message Compressed" WebSocket Framing
Header Bit Header Bit
This section describes a WebSocket framing header bit registration in This section describes a WebSocket framing header bit registration in
the WebSocket Framing Header Bits Registry [RFC6455]. the WebSocket Framing Header Bits Registry [RFC6455].
Header Bit Header Bit
RSV1 RSV1
skipping to change at page 18, line 5 skipping to change at page 18, line 5
The message is compressed or not. The message is compressed or not.
Reference Reference
Section 4 of this document. Section 4 of this document.
The "Per-message Compressed" framing header bit is used on the first The "Per-message Compressed" framing header bit is used on the first
fragment of non-control messages to indicate whether the payload of fragment of non-control messages to indicate whether the payload of
the message is compressed by the Per-message Compression Extension or the message is compressed by the Per-message Compression Extension or
not. not.
7.3. WebSocket Per-message Compression Method Name Registry
This specification creates a new IANA registry for names of
compression methods to be used with the WebSocket Per-message
Compression Extension in accordance with the principles set out in
[RFC5226].
As part of this registry, IANA maintains the following information:
Method Identifier
The identifier of the method, as will be used in the method
description as defined Section 3 of this specification. The value
must conform to the method-name ABNF as defined in Section 3 of
this specification.
Method Common Name
The name of the method, as the method is generally referred to.
Method Definition
A reference to the document in which the method being used with
this extension is defined.
WebSocket Per-message Compression method names are to be subject to
the "First Come First Served" IANA registration policy [RFC5226].
IANA has added initial values to the registry as follows.
+------------+-------------+---------------+
| Identifier | Common Name | Definition |
+------------+-------------+---------------+
| deflate | DEFLATE | This document |
+------------+-------------+---------------+
8. Acknowledgements 8. Acknowledgements
Special thanks to Patrick McManus who wrote up the initial Special thanks to Patrick McManus who wrote up the initial
specification of DEFLATE based compression extension for the specification of DEFLATE based compression extension for the
WebSocket Protocol to which I referred to write this specification. WebSocket Protocol to which I referred to write this specification.
Thank you to the following people who participated in discussions on
the HyBi WG and contributed ideas and/or provided detailed reviews
(the list is likely to be incomplete): Alexey Melnikov, Arman
Djusupov, Bjoern Hoehrmann, Brian McKelvey, Greg Wilkins, Inaki Baz
Castillo, Jamie Lokier, Joakim Erdfelt, John A. Tamplin, Julian
Reschke, Kenichi Ishibashi, Mark Nottingham, Peter Thorson, Roberto
Peon and Simone Bordet. Note that people listed above didn't
necessarily endorse the end result of this work.
9. References 9. References
9.1. Normative References 9.1. Normative References
[RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an
IANA Considerations Section in RFCs", BCP 26, RFC 5226,
May 2008.
[RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", STD 68, RFC 5234, January 2008. Specifications: ABNF", STD 68, RFC 5234, January 2008.
[RFC6455] Fette, I. and A. Melnikov, "The WebSocket Protocol", [RFC6455] Fette, I. and A. Melnikov, "The WebSocket Protocol",
RFC 6455, December 2011. RFC 6455, December 2011.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997. Requirement Levels", BCP 14, RFC 2119, March 1997.
[LZ77] Ziv, J. and A. Lempel, "A Universal Algorithm for [LZ77] Ziv, J. and A. Lempel, "A Universal Algorithm for
 End of changes. 80 change blocks. 
265 lines changed or deleted 219 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/