title: Accept request headers are "text/html,application/xhtm ...(etc)" when I want "application/json" in zf2 client code
body: <p>I've got a fully working API set up, and the zf2 client I have set up works in theory, but no matter what, I can't seem to send a JSON request from my client to the API. Whenever I test it I keep getting the following headers which in turn return a 406 error:</p>
  
  <pre><code>Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Encoding: gzip, deflate
  Accept-Language: en-US,en;q=0.5
  Connection: keep-alive
  Host: zf2-client.local
  User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0 FirePHP/0.7.4
  x-insight: activate
  </code></pre>
  
  <p>Now here's the class I'm using for this and the following is my request setup method. I have done some trials to get the headers in there, but they just don't work and i can't figure out why. As I said the API I'm consuming usually returns a perfectly fine json script, but right now it seems the headers are making it impossible for me to get the necesary information.</p>
  
  <pre><code>protected static function doRequest($url, array $postData = null, $method = Request::METHOD_GET)
  {
      $client = self::getClientInstance();
      $client-&gt;setUri($url);
    /*
   Third attempt Also Didn't work
  
   $client
       -&gt;setHeaders([
       'Content-Type' =&gt; 'application/json',
       ])
       -&gt;setOptions(['sslverifypeer' =&gt; false])
       -&gt;setMethod('POST')
       -&gt;setRawBody(Json::encode($params));
     */
    $client-&gt;setMethod($method);
  
  
    /* 
   seccond attempt still not working
  
   $client-&gt;setHeaders(array(
   Zend\Http\Header\Accept::fromString('Accept: application/json'),
   'Accept-Encoding' =&gt; 'json',
   'X-Powered-By: Zend Framework',
   ));
    */
  
    //first attempt at adding a working application/json header      
    // $acceptHeader = Zend\Http\Header\Accept::fromString('Accept: application/json');
    //$client-&gt;getHeaders()-&gt;addHeader($acceptHeader);
  
      if ($postData !== null) {
          $client-&gt;setParameterPost($postData);
      }
  
      $response = $client-&gt;send();
  
      if ($response-&gt;isSuccess()) {
          return JsonDecoder::decode($response-&gt;getBody(), Json::TYPE_ARRAY);
      } else {
          $logger = new Logger;
          $logger-&gt;addWriter(new Stream('data/logs/apiclient.log'));
          $logger-&gt;debug($response-&gt;getBody());
          return FALSE;
      }
  }
  </code></pre>
  
  <p>Any and all help is welcome. Thank you for your time and effort :)</p>