Reputation: 126327
How do I configure Sinatra to omit the Date
& Server
HTTP response headers? I also want to omit the Content-Type
& Content-Length
headers when there's no response body. I'm building a REST API server for an iPhone app. My iPhone app doesn't use these headers, and I want to be as efficient as possible.
I tried adding the following after filter, but the headers are still included.
after do
response.headers.delete('Date')
response.headers.delete('Server')
end
Upvotes: 1
Views: 928
Reputation: 71
A header can be effectively deleted from a Sinatra response by setting it to an empty string. (Not nil, but '') e.g.:
get '/myroute/nodate' do
response.headers['Date']=''
body="Hello, No Date header in my header!"
end # get
Upvotes: 2