The POST method only validates $_SERVER['CONTENT_TYPE'] for 'application/x-www-form-urlencoded' and not multipart/form-data. This match makes sure multipart passes as well.
Not sure whether this is the way to do it, but it works.

CommentFileSizeAuthor
RESTServer-multipart.patch768 bytestoemaz

Comments

lasconic’s picture

A better patch would be

if ($_SERVER['CONTENT_TYPE'] == 'application/x-www-form-urlencoded' || (strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== FALSE)) {

since strpos does not play nice with == 0

matslats’s picture

Better still, since my client is adding "; charset=UTF-8" to the Content_type header, and since, if that if statement fails, it goes on to run case 'PUT'

 private function parseRequest($method, $controller) {
    switch ($method) {
      case 'POST':
        $types = array('application/x-www-form-urlencoded', 'multipart/form-data');
        foreach ($types as $type) {
          if (strpos($_SERVER['CONTENT_TYPE'], $type) ===0 {
           //why is it even important to check the content_type?
            return $_POST;
          }
        }
        services_error('POSTed unnaceptable content_type in header: '. $_SERVER['CONTENT_TYPE']);
      case 'PUT':
...
justageek’s picture

Yeah, isn't this required if we want to upload a file to a REST URL?