Problem/Motivation

ContentNegotitation::getContentType() is not checking the format correctly. So basically if you try to do a GET request for a node, requesting for a hal_json format or json, you will receive html instead of the correct format.

Proposed resolution

Obtain the format from the request. I think the tests are working because we add _format directly

      // Read it over the REST API.
      $response = $this->httpRequest($entity->urlInfo()->setRouteParameter('_format', $this->defaultFormat), 'GET');
      $this->assertResponse('200', 'HTTP response code is correct.');
      $this->assertHeader('content-type', $this->defaultMimeType);
      $data = Json::decode($response);

I'm not sure why we are not obtaining the format... we are trying to obtain the format from the query and not sure if I'm missing something that has been changed and thats why we are doing it...

    if ($request->query->has('_format')) {
      return $request->query->get('_format');
    }
CommentFileSizeAuthor
request_format.patch946 bytesmarthinal

Comments

marthinal created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, request_format.patch, failed testing.

penyaskito’s picture

marthinal’s picture

Status: Needs work » Closed (works as designed)

OMG :) Ok I see

Many thanks!!!!