Skip to content

Instantly share code, notes, and snippets.

@adamlundrigan
Created July 17, 2012 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamlundrigan/cd57d65055cde28af80c to your computer and use it in GitHub Desktop.
Save adamlundrigan/cd57d65055cde28af80c to your computer and use it in GitHub Desktop.

After updating ZF2 application to latest master (9f4dd7f13c) all controllers return an empty JSON response:

{"content":[]}

Tracing JsonRenderer::selectRenderer, $match at Line 106 succeeds because the browser (Google Chrome 18) sends */* in the Accept header, which triggers the JsonRenderer despite the fact that text/html is the primary Accept type and the controller returns a ViewModel.

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-GB,en-US;q=0.8,en;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Host:XXXXXX
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.19 (KHTML, like Gecko) Ubuntu/12.04 Chromium/18.0.1025.168 Chrome/18.0.1025.168 Safari/535.19
// var_dump() of $match from JsonStrategy L106 (https://github.com/zendframework/zf2/blob/master/library/Zend/View/Strategy/JsonStrategy.php#L106)
object(Zend\Http\Header\Accept\FieldValuePart\AcceptFieldValuePart)[379]
private 'internalValues' (Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePart) =>
object(stdClass)[378]
public 'typeString' => string '*/*' (length=3)
public 'type' => string '*' (length=1)
public 'subtype' => string '*' (length=1)
public 'subtypeRaw' => string '*' (length=1)
public 'format' => string '*' (length=1)
public 'priority' => string '0.8' (length=3)
public 'params' =>
array (size=1)
'q' => string '0.8' (length=3)
public 'raw' => string '*/*;q=0.8' (length=9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment