We have some working code in #781972: Use RestWS for non-RDFa serializations and content negotiation in Drupal 7 to add extra RDF serialization format to RestWS, but we also need to be able to hook into the decision process when RestWS handles a request and choose the format to output the entity. Right now it works if you only have one MIME type, e.g.:

curl -H "Accept: application/x-turtle" http://localhost/node/1

will give you Turtle output. But we next need to handle proper conneg to answer 'Accept:' headers with wildcards and q-values.

Looks like hook_restws_request_alter($request) might be what we need here, so by looking at the HTTP accept header, we might be able to change 'format' to what we want, using some library:
- ARC2 (conneg support is not great, but it's worth reinvestigating. pro: we already require this lib)
- ptlis conneg library
- easypub by Toby Inkster

Comments

clayball’s picture

Would it make sense to roll our own conneg API or module instead of relying on ARC2 or some other 'third-party' library? Especially if other modules may want to use it.

Rolling our own conneg may require more work but it seems the benefit would be worth it.

This would also resolve some current issues like, 1124580 (http://drupal.org/node/1124580).

Thoughts?

scor’s picture

Content negotiation is a complex thing to do if you want to do it right, and it is not Drupal specific. If we were to use ARC2's conneg, then we would not require any new library.

I don't see how this would solve #1124580: Add extra measures to prevent errors when ARC library cannot be found....

@cwells73, you can use the syntax #1124580: Add extra measures to prevent errors when ARC library cannot be found. to link to issues easily (see instructions in the input format fieldset in the comment form ;)

clayball’s picture

@scor, thanks for the tip.

Point taken. I was just trying to think of a way to remove the ARC lib requirement. Then, with the ARC lib requirement removed, so would be any issue regarding ARC lib ;-)