Skip to content

Commit 2f80d1e

Browse files
committed
Push resources as fetch - Fix #3107
1 parent 97d765b commit 2f80d1e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

features/push_relations/push.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Feature: Push relations using HTTP/2
99
Given there are 2 dummy objects with relatedDummy
1010
When I add "Content-Type" header equal to "application/ld+json"
1111
And I send a "GET" request to "/dummies"
12-
Then the header "Link" should be equal to '</related_dummies/1>; rel="preload",</related_dummies/2>; rel="preload",<http://example.com/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'
12+
Then the header "Link" should be equal to '</related_dummies/1>; rel="preload"; as="fetch",</related_dummies/2>; rel="preload"; as="fetch",<http://example.com/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'
1313

1414
Scenario: Push the relations of an item
1515
When I add "Content-Type" header equal to "application/ld+json"
1616
And I send a "GET" request to "/dummies/1"
17-
Then the header "Link" should be equal to '</related_dummies/1>; rel="preload",<http://example.com/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'
17+
Then the header "Link" should be equal to '</related_dummies/1>; rel="preload"; as="fetch",<http://example.com/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'

src/EventListener/SerializeListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function onKernelView(GetResponseForControllerResultEvent $event): void
101101

102102
$linkProvider = $request->attributes->get('_links', new GenericLinkProvider());
103103
foreach ($resourcesToPush as $resourceToPush) {
104-
$linkProvider = $linkProvider->withLink(new Link('preload', $resourceToPush));
104+
$linkProvider = $linkProvider->withLink((new Link('preload', $resourceToPush))->withAttribute('as', 'fetch'));
105105
}
106106
$request->attributes->set('_links', $linkProvider);
107107
}

0 commit comments

Comments
 (0)