/**
  * @param RequestInterface $request
  * @return array
  */
 protected function getRequestDispatchHeaders(RequestInterface $request)
 {
     $headers = $request->getHeaders();
     $headers['Expect'] = '';
     $data = $request->getData();
     $params = $request->getParams();
     $isPostOrPut = in_array($request->getMethod(), ['POST', 'PUT']);
     if ($isPostOrPut && $params instanceof \JsonSerializable) {
         $headers['Content-Type'] = 'application/json';
     }
     if (!array_key_exists('Content-Type', $headers) || is_array($data)) {
         $headers['Content-Type'] = 'application/x-www-form-urlencoded';
     }
     $headers['Content-Type'] .= '; charset=' . $request->getCharset();
     if ($isPostOrPut) {
         $headers['Content-Length'] = strlen($data);
     }
     return $this->prepareHeaders($headers);
 }