diff options
Diffstat (limited to 'docs/requests/streaming.rst')
-rw-r--r-- | docs/requests/streaming.rst | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/docs/requests/streaming.rst b/docs/requests/streaming.rst new file mode 100644 index 0000000..85bf2b6 --- /dev/null +++ b/docs/requests/streaming.rst @@ -0,0 +1,28 @@ +.. _streaming: + +Streaming +========= + +Some backends (see :ref:`backends summary <backends_summary>`) support streaming bodies. If that's the case, you can set a stream of the supported type as a request body using the ``streamBody`` method, instead of the usual ``body`` method. + +.. note:: + + Here, streaming refers to (usually) non-blocking, asynchronous streams of data. To send data which is available as an ``InputStream``, or a file from local storage (which is available as a ``File`` or ``Path``), no special backend support is needed. See the documenttation on :ref:`setting the request body <requestbody>`. + +For example, using the :ref:`akka-http backend <akkahttp>`, a request with a streaming body can be defined as follows:: + + import com.softwaremill.sttp._ + import com.softwaremill.sttp.akkahttp._ + + import akka.stream.scaladsl.Source + import akka.util.ByteString + + val source: Source[ByteString, Any] = ... + + sttp + .streamBody(source) + .post(uri"...") + +.. note:: + + A request with the body set as a stream can only be sent using a backend supporting exactly the given type of streams. |