[yast-devel] Re: [yast-commit] <rest-service> master : Use format instead of content type, as it seems to set the
* Duncan Mac-Vicar P <dmacvicar@suse.de> [Aug 25. 2009 00:04]:
ref: refs/heads/master commit 72faf37c3f8dda4ab91a97f677f8833a775bded8 Author: Duncan Mac-Vicar P <dmacvicar@suse.de> Date: Tue Aug 25 00:01:33 2009 +0200
Use format instead of content type, as it seems to set the content type too.
Hmm, this looks 'fishy' to me. Actually, both ways (@request.accept and setting :format) should work. The (http-wise and restful) correct way is setting the http 'accept' header to the list of mime types (yes, there can be multiple) acceptable by the client. The server is then free to choose one of them. The :format is a Rails extension to support setting the mime type via the URL. Just look at the default routes.rb entry: map.connect ':controller/:action/:id.:format' This is basically a regexp saying that if the url contains two slashes and a dot its to be parsed as controller-slash-action-slash-id-dot-format Summary: Honoring the accept header is a 'must', honoring the :format extension a 'can'. Hth, Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
On Tuesday 25 August 2009 08:12:56 Klaus Kaempf wrote:
* Duncan Mac-Vicar P <dmacvicar@suse.de> [Aug 25. 2009 00:04]:
ref: refs/heads/master commit 72faf37c3f8dda4ab91a97f677f8833a775bded8 Author: Duncan Mac-Vicar P <dmacvicar@suse.de> Date: Tue Aug 25 00:01:33 2009 +0200
Use format instead of content type, as it seems to set the content type too.
Hmm, this looks 'fishy' to me. Actually, both ways (@request.accept and setting :format) should work. The (http-wise and restful) correct way is setting the http 'accept' header to the list of mime types (yes, there can be multiple) acceptable by the client. The server is then free to choose one of them.
I just tried both (setting the content type header) manually and using the API (passing format to get call) and both do the same. I don't have evidence that using format => foo adds only the extension. It may set the content-type. And when having the choice to alter a parameter manually or to use the API, I think we should use the API. -- Duncan Mac-Vicar P. - Engineering Manager, YaST SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
* Duncan Mac-Vicar Prett <dmacvicar@suse.de> [Aug 26. 2009 13:13]:
On Tuesday 25 August 2009 08:12:56 Klaus Kaempf wrote:
Hmm, this looks 'fishy' to me. Actually, both ways (@request.accept and setting :format) should work. The (http-wise and restful) correct way is setting the http 'accept' header to the list of mime types (yes, there can be multiple) acceptable by the client. The server is then free to choose one of them.
I just tried both (setting the content type header) manually and using the API (passing format to get call) and both do the same.
Good.
I don't have evidence that using format => foo adds only the extension. It may set the content-type.
It might do, if used outside of tests. Using it inside tests, bypassing the dispatcher, might have different results, i.e. requiring the :format value to be a string.
And when having the choice to alter a parameter manually or to use the API, I think we should use the API.
Agreed. However, on the receiver side, the http header is authorative, not an .xml or .json url extension. Klaus --- SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (2)
-
Duncan Mac-Vicar Prett
-
Klaus Kaempf