Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body yielded non-string value #1611

Closed
fangzhu19880123 opened this issue Apr 10, 2017 · 6 comments
Closed

Body yielded non-string value #1611

fangzhu19880123 opened this issue Apr 10, 2017 · 6 comments
Labels

Comments

@fangzhu19880123
Copy link

delete ':id' do
  @pop.destroy
end

when i use delete method and is not set the body, the default status is 204, the body is empty, but response_object is true. then it will return

response_object = file || [body || response_object]

then the method after of Middleware::Formatter will return response_object

if Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status)
  @app_response
else
  build_formatted_response(status, headers, bodies)
end

Rack will check the body must string, throw this error

@dblock
Copy link
Member

dblock commented Apr 10, 2017

Is this any different on HEAD? See #1579.

@dblock dblock added the bug? label Apr 10, 2017
@jlfaber
Copy link
Contributor

jlfaber commented Apr 10, 2017

If that destroy call is being made on a Sequel::Model object then it's going to return the object itself. Since that's the last statement in the block, that's what being used as the response object. Adding a body false should give you the 204/empty body you're looking for.

@fangzhu19880123
Copy link
Author

I know, but i think it should be

        # When the body is empty, response_object is present, set response_object to body
        @body ||= response_object

        # The Body commonly is an Array of Strings, the application instance itself, or a File-like object.
        response_object = file || body

@fangzhu19880123
Copy link
Author

Maybe it's my version has a problem, I have a look

@fangzhu19880123
Copy link
Author

When will release the new tag

@dblock
Copy link
Member

dblock commented Apr 11, 2017

@fangzhu19880123 Sounds like this solved your problem? I'm going to close this.

See #1612 for release date/discussion.

@dblock dblock closed this as completed Apr 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants