http-headersservicestack

How To Support Range Requests In ServiceStack For application/json


The ServiceStack docs say that "HTTP Partial Content Support is added in true ServiceStack-style where it's now automatically and transparently enabled for any existing services returning" and then it then lists the 5 content types supported:-

https://docs.servicestack.net/service-return-types#partial-content-support

I have a service returning application/json and, as expected, adding a range http header to a request to the existing service made no difference to the response i.e. the range header seemed to be ignored and the full response was generated.

Is it possible to make the partial content functionality in ServiceStack work with application/json?


Solution

  • Did you return the JSON Response in a HttpResult as per the Partial Content Support docs:

    return new HttpResult(json, MimeTypes.Json);