2025-07-14 23:48:24 +08:00
|
|
|
[[webflux-range]]
|
|
|
|
= Range Requests
|
|
|
|
:page-section-summary-toc: 1
|
|
|
|
|
|
|
|
[.small]#xref:web/webmvc/mvc-range.adoc[See equivalent in the Servlet stack]#
|
|
|
|
|
|
|
|
Spring WebFlux supports https://datatracker.ietf.org/doc/html/rfc9110#section-14[RFC 9110]
|
|
|
|
range requests. For an overview, see the
|
|
|
|
https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Range_requests[Ranger Requests]
|
|
|
|
Mozilla guide.
|
|
|
|
|
|
|
|
The `Range` header is parsed and handled transparently in WebFlux when an annotated
|
|
|
|
controller returns a `Resource` or `ResponseEntity<Resource>`, or a functional endpoint
|
|
|
|
xref:web/webflux-functional.adoc#webflux-fn-resources[serves a `Resource`]. `Range` header
|
|
|
|
support is also transparently handled when serving
|
|
|
|
xref:web/webflux/config.adoc#webflux-config-static-resources[static resources].
|
|
|
|
|
2025-08-12 13:55:36 +08:00
|
|
|
TIP: The `Resource` must not be an `InputStreamResource` and with `ResponseEntity<Resource>`,
|
|
|
|
the status of the response must be 200.
|
|
|
|
|
2025-07-14 23:48:24 +08:00
|
|
|
The underlying support is in the `HttpRange` class, which exposes methods to parse
|
|
|
|
`Range` headers and split a `Resource` into a `List<ResourceRegion>` that in turn can be
|
|
|
|
then written to the response via `ResourceRegionEncoder` and `ResourceHttpMessageWriter`.
|