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;
CommentFileSizeAuthor
#4 1242270-restws-mime.patch526 bytesamitaibu

Comments

amitaibu’s picture

I also get the error and the code proposed works.

amitaibu’s picture

Status: Active » Needs review

Here's the patch. If committed, please credit garethsprice.

klausi’s picture

Status: Needs review » Needs work

Patch is missing?

amitaibu’s picture

Status: Needs work » Needs review
StatusFileSize
new526 bytes

Oops ;)

klausi’s picture

Status: Needs review » Fixed

Committed, thanks.

Automatically closed -- issue fixed for 2 weeks with no activity.