<remark>Per a vote of the Jabber Council, advanced status to Draft.</remark>
</revision>
<revision>
<version>0.5</version>
<date>2005-05-18</date>
<initials>psa</initials>
<remark>Modifications to address Council feedback: used RFC 3920 terminology; specified error conditions; specified ZLIB as mandatory to implement.</remark>
</revision>
<revision>
<version>0.4</version>
<date>2005-05-11</date>
<initials>psa</initials>
<remark>Corrected several errors in the schemas.</remark>
<p>&xmppcore; specifies the use of Transport Layer Security (TLS; see &rfc2246;) for encryption of XML streams, and TLS includes the ability to compress encrypted traffic (see &rfc3749;). However, not all computing platforms are able to implement TLS, and traffic compression may be desirable for communication by applications on such computing platforms. This document defines a mechanism for negotiating the compression of XML streams outside the context of TLS.</p>
<p>Note: The <compression/> element MUST contain at least one <method/> child element. Each <method/> element MUST contain XML character data that specifies the name of a compression method, and such method names SHOULD be registered as described in the <linkurl='#registrar-methods'>Compression Methods Registry</link> section of this document. The methods SHOULD be provided in order of preference.</p>
<p>The initiating entity then MAY request compression by specifying one of the methods advertised by the receiving entity:</p>
<p>Note: If the initiating entity did not understand any of the advertised compression methods, it SHOULD ignore the compression option and proceed as if no compression methods were advertised.</p>
<p>If the initiating entity requests a stream compression method that is not supported by the receiving entity, the receiving entity MUST return an <unsupported-method/> error:</p>
<examplecaption='Receiving Entity Reports That Method is Unsupported'><![CDATA[
<p>If the receiving entity finds the requested method unacceptable or unworkable for any other reason, it MUST return a <setup-failed/> error:</p>
<examplecaption='Receiving Entity Reports That Negotiation of Stream Compression Failed'><![CDATA[
<p>Note: Failure of the negotiation SHOULD NOT be treated as an unrecoverable error and therefore SHOULD NOT result in a stream error. In particular, the initiating entity is free to retry the compression negotiation if it fails.</p>
<p>If no error occurs, the receiving entity MUST inform the initiating entity that compression has been successfully negotiated:</p>
<examplecaption='Receiving Entity Acknowledges Negotiation of Stream Compression'><![CDATA[
<p>Both entities MUST now consider the previous (uncompressed) stream to be null and void, just as with TLS negotiation and SASL negotiation (as specified in <cite>RFC 3920</cite>) and MUST begin compressed communications with a new (compressed) stream. Therefore the initiating entity MUST initiate a new stream to the receiving entity:</p>
<examplecaption='Initiating Entity Initiates New (Compressed) Stream'><![CDATA[
<stream:stream
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'
to='shakespeare.lit'>
]]></example>
<p>If compression processing fails after the new (compressed) stream has been established, the entity that detects the error SHOULD generate a stream error and close the stream:</p>
<examplecaption='Entity Closes Stream Because of a Processing Error'><![CDATA[
<p>The initiating entity and receiving entity MAY support &xep0020; for more fine-grained negotiation of parameters (such as compression levels). Such support is OPTIONAL, and the initiating entity should expect that the receiving entity may not support feature negotiation. Because use of &xep0030; to discover negotiable features is inconvenient during stream negotiation, the initiating entity SHOULD negotiate only features that are registered for use with the 'http://jabber.org/protocol/compress' FORM_TYPE as described in the <linkurl="#registrar-formtype">Field Standardization</link> section of this document.</p>
<p>If the receiving entity does not support the use of feature negotiation within stream compression, it MUST ignore the <feature/> element.</p>
<p>If the receiving entity does not support one or more of the included features, it MUST return a <failure/> containing an XMPP &feature; error and SHOULD specify the feature(s) not implemented in an XMPP <text/> element.</p>
<examplecaption="Receiving entity does not support a feature"><![CDATA[
<p>If the receiving entity supports none of the included options for a certain feature, it MUST return a <failure/> containing an XMPP ¬acceptable; error and SHOULD specify the option(s) not supported in an XMPP <text/> element.</p>
<examplecaption="Receiving entity does not support an option"><![CDATA[
<li>If stream compression is negotiated, it MUST be used in both directions.</li>
<li>TLS compression and stream compression SHOULD NOT be used simultaneously.</li>
<li>If both TLS (whether including TLS compression or not) and stream compression are used, then TLS MUST be negotiated first, followed by negotiation of stream compression.</li>
<p>A compliant implementation MUST implement the ZLIB compression method as specified in &rfc1950;. All other methods are OPTIONAL; such methods may be defined in future specifications or by registration as described in the <linkurl='#registrar-methods'>Compression Methods Registry</link> section of this document.</p>
<p>When using ZLIB for compression, the sending application SHOULD complete a partial flush of ZLIB when its current send is complete. Note that this statement is deliberately somewhat vague: the sending application may end up performing this partial flush after sending every XML stanza, but on the other hand may perform the partial flush only after sending a group of stanzas that have been queued up for delivery. When to flush the state of the compression application is up to the sending application.</p>
</section2>
<section2topic='LZW (DCLZ)'anchor='impl-lzw'>
<p>The "LZW" compression algorithm was originally developed by Abraham Lempel and Jacob Ziv, subsequently improved by Terry Welch <note>See "A Technique for High-Performance Data Compression", <cite>Computer</cite> (June 1984), pp. 8-19.</note>, and patented by Sperry Corporation (later Unisys Corporation) as U.S. Patent Number 4,464,650 <note>See <<linkurl='http://patft.uspto.gov/netacgi/nph-Parser?patentnumber=4,464,650'>http://patft.uspto.gov/netacgi/nph-Parser?patentnumber=4,464,650</link>>.</note>. This patent expired on June 20, 2003 <note>See <<linkurl='http://www.unisys.com/about__unisys/lzw'>http://www.unisys.com/about__unisys/lzw</link>>.</note> and therefore implementations are no longer patent-encumbered. If this algorithm is supported, implementations SHOULD follow the specification provided by Ecma International in &ecma151; under the name "DCLZ".</p>
<p>Stream encryption via TLS (as defined in <cite>RFC 3920</cite>) and stream compression (as defined herein) are not mutually exclusive, but stream encryption via TLS MUST be negotiated before negotiation of stream compression in order to secure the stream.</p>
<p>The XMPP Registrar maintains a registry of compression methods at <<linkurl='http://www.jabber.org/registrar/compress.html'>http://www.jabber.org/registrar/compress.html</link>>.</p>
<p>&xep0068; defines a process for standardizing the fields used within Data Forms qualified by a particular namespace. Reserved fields shall be registered with the XMPP Registrar as necessary.</p>