The escapeBody extension exercises the funtionality of a PEPExtension that either encrypts or signs a document. Because many such opperations may be performed on documents that are very large, it is prohibitive to make multiple passes through the document. Unfortunately, this would be required if the extension changed the size of the document (especially desirable with compression) and the agent had to pass a content-length field before the body.
There are many solutions to this, like keeping a compressed size table, and updating it with two passes when a new file is encountered or when the datestamp has changed on a cached file. A single-pass solution is to create a required hop-by-hop extension.
As a result of makeing one pass through the document, the size sent reflects the "expanded" size, not the transmitted size. This means that all agents that handle the body must speak the extension well enougth to unescape the body to either calculate the "expanded" size, or look for the end sequence at the end of the body.