Skip to content

Add text content type to redirects #1157

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

Closed
wants to merge 1 commit into from

Conversation

franzliedke
Copy link

The redirect helper returned an empty response, which confused the XML and JSON helpers (e.g. when rendering in a browser).

This sets the content type explicitly, which solves that problem. :)

@dblock
Copy link
Member

dblock commented Sep 18, 2015

At the very least this needs tests and a CHANGELOG entry.

This has been discussed before though and the consensus was that a redirect should not set a content type because there's no content. If you find an RFC that says otherwise happy to consider. I'll leave this open for now.

@franzliedke
Copy link
Author

Well, redirects are unusable for me with content_type :xml, content_type :json as well as default_format :json in my base API class. As I said, the formatters try to interpret the empty body as JSON or XML and fail.

If you give me the go-ahead, I'll gladly add a test.

@dblock
Copy link
Member

dblock commented Sep 18, 2015

I am just confused to why they are not usable given that it's the "correct" behavior?

@franzliedke
Copy link
Author

When I redirect, I obviously don't want to render any JSON or XML, so the formatters shouldn't even try.

@dblock
Copy link
Member

dblock commented Sep 19, 2015

Maybe I am missing the point, can you explain "which confused the XML and JSON helpers" please? I am not trying to be difficult, just trying to help :)

@franzliedke
Copy link
Author

Here you go:

get 'me' do
  redirect "users/#{current_user.id}"
end

With default_format set to XML, I get this output:

<error>
  <message>cannot convert String to xml</message>
</error>

For JSON, it works now. Weird.

@dblock
Copy link
Member

dblock commented Sep 21, 2015

Ok this is what I'd expect. I think we need defined behavior for XML here, which is not an error. It's the same problem as discussed in #1159, can we merge these two discussions?

@dblock
Copy link
Member

dblock commented Sep 21, 2015

I am going to close this in favor of #1162, without merging. Lets discuss what the "right fix" would be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants