Hello!
On Wed, Dec 11, 2013 at 8:05 PM, caquino wrote:
> Someone knows if it's possible to return a 206 Partial content using
> ngx.exit?
>
It works for me with nginx 1.4.3 + ngx_lua 0.9.x on Linux x86_64.
Consider the following minimal example:
location = /t {
content_by_lua 'ngx.exit(206)';
}
Below is the test result on my side:
$ curl -i localhost:8080/t
HTTP/1.1 206 Partial Content
Server: nginx/1.4.3
Date: Thu, 12 Dec 2013 21:03:10 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
If you have custom response headers or response body, then you must
set ngx.status to 206 at the very beginning. Below is such an example:
location = /t {
content_by_lua '
ngx.status = 206
ngx.header["Content-Range"] = "bytes 0-5/10"
ngx.say("hello")
ngx.exit(206)
';
}
And below is my test result:
$ curl -i localhost:8080/t
HTTP/1.1 206 Partial Content
Server: nginx/1.4.3
Date: Thu, 12 Dec 2013 21:06:05 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
Content-Range: bytes 0-5/10
hello
You can try out these examples on your side.
> On my lab it seen that using ngx.exit(206) has no effect at all, it keeps
> return 200 responses.
>
The next time you report a problem, please try to provide a minimal
code example and the versions of the related software components
you're using so as to save our time :)
Thanks!
-agentzh