pekko/akka-docs/rst/java/http/routing-dsl/directives/timeout-directives/withRequestTimeoutResponse.rst
gosubpl 4b89fcd643 +doc #20466 akka http java dsl example snippets timeout directives (#20812)
* #20466 added checks to the TimeoutDirectivesExampleSpec

* #20466 added missing Java directive wrapper, added Java test, added some comments to Scala spec

* #20466 test minor fixes (typos, comments, unused code)

* #20466 replaced placeholders with proper snippets in Java docs

* #20466 added proper withRequestTimeout example to JavaTestServer

* #20466 comment - clarifies the request-timeout = infinite case

* #20466 post-review changes (#20812)
2016-06-22 01:55:28 +02:00

27 lines
No EOL
1.1 KiB
ReStructuredText

.. _-withRequestTimeoutResponse-java-:
withRequestTimeoutResponse
==========================
Description
-----------
Allows customising the ``HttpResponse`` that will be sent to clients in case of a :ref:`request-timeout-java`.
See also :ref:`-withRequestTimeout-java-` or :ref:`-withoutRequestTimeout-java-` if interested in dynamically changing the timeout
for a given route instead.
.. warning::
Please note that setting handler is inherently racy as the timeout is measured from starting to handle the request
to its deadline, thus if the timeout triggers before the ``withRequestTimeoutResponse`` executed it would have emitted
the default timeout HttpResponse.
In practice this can only be a problem with very tight timeouts, so with default settings
of request timeouts being measured in seconds it shouldn't be a problem in reality (though certainly a possibility still).
To learn more about various timeouts in Akka HTTP and how to configure them see :ref:`http-timeouts-java`.
Example
-------
.. includecode2:: ../../../../code/docs/http/javadsl/server/directives/TimeoutDirectivesExamplesTest.java
:snippet: withRequestTimeoutResponse