public function testAddsContentEncodingWhenSetOnBody()
 {
     $visitor = new Visitor();
     $param = $this->getNestedCommand('body')->getParam('foo')->setSentAs('Foo');
     $body = EntityBody::factory('foo');
     $body->compress();
     $visitor->visit($this->command, $this->request, $param, $body);
     $this->assertEquals('gzip', (string) $this->request->getHeader('Content-Encoding'));
 }
 /**
  * {@inheritdoc}
  */
 public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
 {
     $filteredValue = $param->filter($value);
     if (null !== $this->serializer && (is_object($filteredValue) || is_array($filteredValue))) {
         switch ($param->getSentAs()) {
             case 'json':
                 $request->setHeader('Content-Type', 'application/json');
                 $contentType = 'json';
                 break;
             case 'yml':
             case 'yaml':
                 $request->setHeader('Content-Type', 'application/yaml');
                 $contentType = 'yml';
                 break;
             default:
                 $request->setHeader('Content-Type', 'application/xml');
                 $contentType = 'xml';
                 break;
         }
         $context = SerializationContext::create();
         if (null !== ($groups = $param->getData('jms_serializer.groups'))) {
             $context->setGroups($groups);
         }
         if (null !== ($version = $param->getData('jms_serializer.version'))) {
             $context->setVersion($version);
         }
         if (null !== ($nulls = $param->getData('jms_serializer.serialize_nulls'))) {
             $context->setSerializeNull($nulls);
         }
         if (true === $param->getData('jms_serializer.max_depth_checks')) {
             $context->enableMaxDepthChecks();
         }
         $value = $this->serializer->serialize($filteredValue, $contentType, $context);
     }
     parent::visit($command, $request, $param, $value);
 }