=doc #18496 add scala docs for coding directives

This commit is contained in:
Martynas Mickevicius 2015-10-14 16:33:51 +02:00
parent 92e2ac21f0
commit 073c201e75
7 changed files with 42 additions and 43 deletions

View file

@ -3,9 +3,6 @@
encodeResponse
==============
Tries to encode the response with the specified ``Encoder`` or rejects the request with an
``UnacceptedResponseEncodingRejection(supportedEncodings)``.
Signature
---------
@ -15,24 +12,16 @@ Signature
Description
-----------
The directive automatically applies the ``autoChunkFileBytes`` directive as well to avoid having to load
an entire file into JVM heap.
Encodes the response with the encoding that is requested by the client via the ``Accept-Encoding`` header or rejects the request with an ``UnacceptedResponseEncodingRejection(supportedEncodings)``.
The parameter to the directive is either just an ``Encoder`` or all of an ``Encoder``, a threshold, and a
chunk size to configure the automatically applied ``autoChunkFileBytes`` directive.
The response encoding is determined by the rules specified in RFC7231_.
The ``encodeResponse`` directive is the building block for the ``compressResponse`` and
``compressResponseIfRequested`` directives.
``encodeResponse``, ``compressResponse``, and ``compressResponseIfRequested`` are related like this::
compressResponse(Gzip) = encodeResponse(Gzip)
compressResponse(a, b, c) = encodeResponse(a) | encodeResponse(b) | encodeResponse(c)
compressResponse() = encodeResponse(Gzip) | encodeResponse(Deflate) | encodeResponse(NoEncoding)
compressResponseIfRequested() = encodeResponse(NoEncoding) | encodeResponse(Gzip) | encodeResponse(Deflate)
If the ``Accept-Encoding`` header is missing or empty or specifies an encoding other than identity, gzip or deflate then no encoding is used.
Example
-------
.. includecode2:: ../../../../code/docs/http/scaladsl/server/directives/CodingDirectivesExamplesSpec.scala
:snippet: encodeResponse
:snippet: "encodeResponse"
.. _RFC7231: http://tools.ietf.org/html/rfc7231#section-5.3.4