How to return truly empty body in rails? i.e. content-length 0

后端 未结 1 816
不知归路
不知归路 2021-01-04 01:46

I\'m trying to return a 200 status with an empty body but rails returns a body with a single space. i.e. content-length 1

For instance, this code generates a body wi

相关标签:
1条回答
  • 2021-01-04 02:36

    This appears to work

    render :text => ""
    

    For Rails 3, you could use:

    render :nothing => true

    In Rails 5, render :nothing => true is deprecated (planned for removal in 5.1)

    Use

    def action
      head :ok
    end
    

    Credit to this question for the Rails 5 solution.

    0 讨论(0)
提交回复
热议问题