Problem/Motivation
Noticed that my submissions were working in Safari but failing in Firefox when submitting data via POST, PUT, DELETE, etc using jQuery. Safari's browser headers are uploaded as "application/json" whereas Firefox uploads as "application/json; charset=UTF-8". The charset suffix causes the detection of the format to fail.
Not sure if the charset=UTF-8 suffix is common to all Firefox browsers or just mine (FF 5.0.1 on Mac OS/X Snow Leopard).
Proposed resolution
DELETE already handles splitting the $_SERVER['HTTP_ACCEPT'] string up to detect the mimetype correctly. Solution for PUT/POST is to add a similar check that splits the $_SERVER['CONTENT_TYPE'] field on the semi-colon.
[line 228-232 in restws.module]:
case 'POST':
// Get format MIME type form HTTP Content type header.
$parts = explode(';', $_SERVER['CONTENT_TYPE'], 2);
$format = restws_format_mimetype($parts[0]);
break;
Comments
Comment #1
amitaibuI also get the error and the code proposed works.
Comment #2
amitaibuHere's the patch. If committed, please credit garethsprice.
Comment #3
klausiPatch is missing?
Comment #4
amitaibuOops ;)
Comment #5
klausiCommitted, thanks.