in Sinatra 1.x, the new after filter feature does not have access to
response.body (to read or modify). Given this simple app:
require 'rubygems'
require 'sinatra'
after { p response }
get('/') { etag "abc"; "HELLO" }
The response.body comes out as []:
#<Sinatra::Response:0x188bee4 @body=[], ..., @header={"ETag"=>"\"abc
\"", ...>
Notice that the headers set in route block are available. I don't know
if this is expected behaviour or not -- there are no tests for this in
the test suite, but it seems counter-intuitive to me, and the the
README states that:
> After filter are evaluated after each request within the context of the
> request and can also modify the request and response.
Can someone confirm what's the real meaning?
Thanks!,
Karel
P.S.
(My use-case would be to automatically set ETag in an after, globally
in the application -- doing MD5 of the body etc.)
Hi,
in Sinatra 1.x, the new after filter feature does not have access to
response.body (to read or modify). Given this simple app:
require 'rubygems'
require 'sinatra'
after { p response }
get('/') { etag "abc"; "HELLO" }
The response.body comes out as []:
#<Sinatra::Response:0x188bee4 @body=[], ..., @header={"ETag"=>"\"abc
\"", ...>
Notice that the headers set in route block are available. I don't know
if this is expected behaviour or not -- there are no tests for this in
the test suite, but it seems counter-intuitive to me, and the the
README states that:
> After filter are evaluated after each request within the context of the
> request and can also modify the request and response.
Can someone confirm what's the real meaning?
require 'rubygems'
require 'sinatra-sinatra/lib/sinatra'
after { p response }
get('/') { "HELLO
=> #<Sinatra::Response:0x18a3544 @length=0, @header={"Content-
Type"=>"text/html"}, ..., @body=[], @status=200, @block=nil>
Karel
On Feb 24, 11:00 am, Ben Lovell <benjamin.lov...@gmail.com> wrote:
Ben, could you please add a test for it and run it?
Because this fails for me. Again, I don't know what's the expected
behaviour -- but I'd guess I should be able to read/modify the
response.body, _or_ the docs need t be changed....
Thanks,
Karel
--
You received this message because you are subscribed to the Google Groups "sinatrarb" group.
To post to this group, send email to sina...@googlegroups.com.
To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=en.