public function testWithAllOptions()
 {
     $raw = '<value>; rel="rel"; rev="rev"; title="title"; anchor="anchor"; something="some_value"';
     $link = new LinkHeader($raw);
     $this->assertEquals($raw, $link->getOriginalHeader());
     $this->assertEquals('value', $link->getValue());
     $this->assertEquals('rel', $link->getRelation());
     $this->assertEquals('rev', $link->getReverseRelation());
     $this->assertEquals('title', $link->getTitle());
     $this->assertEquals('anchor', $link->getAnchor());
     $this->assertEquals(1, count($link->getExtensions()));
     $this->assertEquals(['something' => 'some_value'], $link->getExtensions());
     $this->assertEquals('some_value', $link->getExtension('something'));
 }
 public function onKernelRequest(KernelEvent $event)
 {
     if (strtoupper($event->getRequest()->getMethod()) !== 'LINK' && strtoupper($event->getRequest()->getMethod()) !== 'UNLINK') {
         return;
     }
     if (!$event->getRequest()->headers->has('link')) {
         throw new BadRequestHttpException('Please specify at least one Link.');
     }
     $requestMethod = $this->urlMatcher->getContext()->getMethod();
     $this->urlMatcher->getContext()->setMethod('GET');
     $links = [];
     /*
      * Due to limitations, multiple same-name headers are sent as comma
      * separated values.
      *
      * This breaks those headers into Link headers following the format
      * http://tools.ietf.org/html/rfc2068#section-19.6.2.4
      */
     foreach (explode(',', $event->getRequest()->headers->get('link')) as $header) {
         $header = trim($header);
         $link = new LinkHeader($header);
         try {
             if ($urlParameters = $this->urlMatcher->match($link->getValue())) {
                 $link->setUrlParameters($urlParameters);
             }
         } catch (ResourceNotFoundException $exception) {
         }
         try {
             $link->setResource($this->resourceTransformer->getResourceProxy($link->getValue()));
         } catch (InvalidArgumentException $e) {
         }
         $links[] = $link;
     }
     $this->urlMatcher->getContext()->setMethod($requestMethod);
     $event->getRequest()->attributes->set('links', $links);
 }