Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-15789

Support range requests for Spring MVC request mapped methods that return a Resource

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 5.0 RC2
    • Fix Version/s: 5.0 RC4
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      I've just been pleased to learn that WebFlux automatically supports range requests to a request mapping method that returns a Resource:

      @RequestMapping(path = "/")
      public Resource test() {
      	return new ByteArrayResource(new byte[] {'a', 'b', 'c', 'd', 'e', 'f'});
      }
      
      $ curl localhost:8080 -H "Range: bytes=2-4" -i
      HTTP/1.1 206 Partial Content
      Accept-Ranges: bytes
      Content-Type: application/octet-stream
      Content-Range: bytes 2-4/6
      Content-Length: 3
      
      cde
      

      Unfortunately, if the same controller is implemented using Spring MVC, the full resource content is returned:

      $ curl localhost:8080 -H "Range: bytes=2-4" -i
      HTTP/1.1 200
      Content-Type: application/json
      Content-Length: 6
      Date: Tue, 18 Jul 2017 13:03:31 GMT
      
      abcdef
      

      It would be beneficial to Boot 2.0's new actuator endpoint infrastructure if Spring MVC offered the same capabilities as WebFlux here.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                bclozel Brian Clozel
                Reporter:
                awilkinson Andy Wilkinson
                Last updater:
                St├ęphane Nicoll
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  1 year, 4 weeks, 2 days ago