This JEP defines a mechanism for compressing XML streams.
NOTICE: The protocol defined herein is a Draft Standard of the Jabber Software Foundation. Implementations are encouraged and the protocol is appropriate for deployment in production systems, but some changes to the protocol are possible before it becomes a Final Standard.
Type: Standards Track
Last Updated: 2005-06-16
JIG: Standards JIG
Approving Body: Jabber Council
Dependencies: XMPP Core
Superseded By: None
Short Name: compress
Schema for feature: <http://jabber.org/protocol/compress/feature.xsd>
Schema for compress: <http://jabber.org/protocol/compress/compress.xsd>
Wiki Page: <http://wiki.jabber.org/index.php/Stream Compression (JEP-0138)>
This Jabber Enhancement Proposal is copyright 1999 - 2005 by the Jabber Software Foundation (JSF) and is in full conformance with the JSF's Intellectual Property Rights Policy <http://www.jabber.org/jsf/ipr-policy.shtml>. This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution License (<http://creativecommons.org/licenses/by/2.5/>).
The preferred venue for discussion of this document is the Standards-JIG discussion list: <http://mail.jabber.org/mailman/listinfo/standards-jig>.
The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the Jabber Software Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this JEP has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.
The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
XMPP Core  specifies the use of Transport Layer Security (TLS; see RFC 2246 ) for encryption of XML streams, and TLS includes the ability to compress encrypted traffic (see RFC 3749 ). 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 JEP defines a mechanism for compressing XML streams outside the context of TLS.
The protocol flow is as follows:
<stream:features> <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/> <compression xmlns='http://jabber.org/features/compress'> <method>zlib</method> </compression> </stream:features>
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 Compression Methods Registry section of this document.
The initiating entity then MAY request compression by specifying one of the methods advertised by the receiving entity:
<compress xmlns='http://jabber.org/protocol/compress'> <method>zlib</method> </compress>
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.
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:
<failure xmlns='http://jabber.org/protocol/compress'> <unsupported-method/> </failure>
If the receiving entity cannot establish compression using the requested method for any other reason, it MUST return a <setup-failed/> error:
<failure xmlns='http://jabber.org/protocol/compress'> <setup-failed/> </failure>
If no error occurs, the receiving entity MUST inform the initiating entity that compression has been established:
Both entities MUST now consider the previous stream to be null and void, just as with TLS negotiation and SASL negotiation (as specified in RFC 3920). Therefore the initiating entity MUST initiate a new stream to the receiving entity:
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' to='shakespeare.lit'>
If compression processing fails after the stream has been established, the entity that detects the error SHOULD generate a stream error and close the stream:
<stream:error> <undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-streams'/> <failure xmlns='http://jabber.org/protocol/compress'/> <processing-failed/> </failure> </stream:error> </stream:stream>
The following business rules apply:
A compliant implementation MUST implement the ZLIB compression method as specified in RFC 1950 . All other methods are OPTIONAL; such methods may be defined in future JEPs or by registration as described in the Compression Methods Registry section of this document.
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.
Stream encryption via TLS (as defined in RFC 3920) 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.
This JEP requires no interaction with the Internet Assigned Numbers Authority (IANA) .
The Jabber Registrar  includes 'http://jabber.org/features/compress' in its registry of stream features.
The Jabber Registrar includes 'http://jabber.org/protocol/compress' in its registry of protocol namespaces.
The Jabber Registrar maintains a registry of compression methods at <http://www.jabber.org/registrar/compress.html>.
In order to submit new values to this registry, the registrant must define an XML fragment of the following form and either include it in the relevant Jabber Enhancement Proposal or send it to the email address <firstname.lastname@example.org>:
<method> <name>the XML character data of the method element</name> <desc>a natural-language description of the compression method</desc> <doc>the document that specifies or registers the compression method</doc> </method>
The registrant may register more than one compression method at a time, each contained in a separate <method/> element.
<method> <name>zlib</name> <desc>the ZLIB compression method as specified in RFC 1950</desc> <doc>JEP-0138</doc> </method>
<?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://jabber.org/features/compress' xmlns='http://jabber.org/features/compress' elementFormDefault='qualified'> <xs:annotation> <xs:documentation> The protocol documented by this schema is defined in JEP-0138: http://www.jabber.org/jeps/jep-0138.html </xs:documentation> </xs:annotation> <xs:element name='compression'> <xs:complexType> <xs:sequence> <xs:element name='method' type='xs:NCName' maxOccurs='unbounded'/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
<?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='http://jabber.org/protocol/compress' xmlns='http://jabber.org/protocol/compress' elementFormDefault='qualified'> <xs:annotation> <xs:documentation> The protocol documented by this schema is defined in JEP-0138: http://www.jabber.org/jeps/jep-0138.html </xs:documentation> </xs:annotation> <xs:element name='compress'> <xs:complexType> <xs:sequence> <xs:element name='method' type='xs:NCName'/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name='compressed' type='empty'/> <xs:element name='failure'> <xs:complexType> <xs:choice> <xs:element name='setup-failed' type='empty'/> <xs:element name='processing-failed' type='empty'/> <xs:element name='unsupported-method' type='empty'/> </xs:choice> </xs:complexType> </xs:element> <xs:simpleType name='empty'> <xs:restriction base='xs:string'> <xs:enumeration value=''/> </xs:restriction> </xs:simpleType> </xs:schema>
5. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.
6. The Jabber Registrar maintains a list of reserved Jabber protocol namespaces as well as registries of parameters used in the context of protocols approved by the Jabber Software Foundation. For further information, see <http://www.jabber.org/registrar/>.