spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Consider adding a section in documentation about byte-range requests in Spring MVC

Open FBibonne opened this issue 5 months ago • 0 comments

Spring MVC (and also Spring WebFlux but I do not know this part very well) has been fully supporting HTTP byte-range requests since version 5.2.5. As Spring MVC is a very complete web framework, one can imagine that it handles HTTP byte-range requests, but it should be mentioned in documentation. Furthermore, the section about byte-range requests should give conditions under which an endpoint can handle range requests (http status code and returned type).

It may be something like that :

Spring MVC automatically handles HTTP byte-range requests (in other words it can return only a part of a resource if asked with an HTTP request with a Range header) in respect to RFC 9110 section14 :

  • since 4.2.0-RC1 for static resources
  • since 5.0.0.RC4 for resources served from a Controller
  • since 5.2.5 for resources served from a functional endpoint

For static resources, there is nothing else to do.

For resources served both from a Controller and a functional endpoint, the body of the response must be of type Resource but not InputStreamResource. And also for resources served from a Controller, the status of the response returned by the controller method must be 200.

NB :

  • I'm not totally sure of the conditions for functional endpoints : maybe condition for status code is not mandatory
  • there is also a good description of what is HTTP byte-range requests in MDN : https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Range_requests

FBibonne avatar Jun 14 '25 07:06 FBibonne