Skip to content

Commit 36cee39

Browse files
authoredJan 13, 2025··
fix(state): skip Content-Location header for GET requests (#6901)
1 parent 1a8dea7 commit 36cee39

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed
 

‎features/hydra/collection.feature

-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ Feature: Collections support
7777
When I send a "GET" request to "/dummies?page=7"
7878
Then the response status code should be 200
7979
And the response should be in JSON
80-
And the header "Content-Location" should be equal to "/dummies.jsonld?page=7"
8180
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
8281
And the JSON should be valid according to this schema:
8382
"""

‎features/main/crud.feature

+9-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Feature: Create-Retrieve-Update-Delete
6060
Then the response status code should be 200
6161
And the response should be in JSON
6262
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
63+
And the header "Content-Location" should not exist
6364
And the JSON should be equal to:
6465
"""
6566
{
@@ -100,13 +101,14 @@ Feature: Create-Retrieve-Update-Delete
100101
Scenario: Get a not found exception
101102
When I send a "GET" request to "/dummies/42"
102103
Then the response status code should be 404
104+
And the header "Content-Location" should not exist
103105

104106
Scenario: Get a collection
105107
When I send a "GET" request to "/dummies"
106108
Then the response status code should be 200
107109
And the response should be in JSON
108110
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
109-
And the header "Content-Location" should be equal to "/dummies.jsonld"
111+
And the header "Content-Location" should not exist
110112
And the JSON should be equal to:
111113
"""
112114
{
@@ -616,6 +618,7 @@ Feature: Create-Retrieve-Update-Delete
616618
Then the response status code should be 200
617619
And the response should be in JSON
618620
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
621+
And the header "Content-Location" should not exist
619622
And the JSON should be equal to:
620623
"""
621624
{
@@ -640,6 +643,7 @@ Feature: Create-Retrieve-Update-Delete
640643
Then the response status code should be 200
641644
And the response should be in JSON
642645
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
646+
And the header "Content-Location" should not exist
643647
And the JSON should be equal to:
644648
"""
645649
{
@@ -657,6 +661,7 @@ Feature: Create-Retrieve-Update-Delete
657661
Then the response status code should be 200
658662
And the response should be in JSON
659663
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
664+
And the header "Content-Location" should not exist
660665
And the JSON should be equal to:
661666
"""
662667
{
@@ -676,6 +681,7 @@ Feature: Create-Retrieve-Update-Delete
676681
Then the response status code should be 200
677682
And the response should be in JSON
678683
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
684+
And the header "Content-Location" should not exist
679685
And the JSON should be equal to:
680686
"""
681687
{
@@ -718,6 +724,7 @@ Feature: Create-Retrieve-Update-Delete
718724
Then the response status code should be 200
719725
And the response should be in JSON
720726
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
727+
And the header "Content-Location" should not exist
721728
And the JSON should be equal to:
722729
"""
723730
{
@@ -737,6 +744,7 @@ Feature: Create-Retrieve-Update-Delete
737744
Then the response status code should be 200
738745
And the response should be in JSON
739746
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
747+
And the header "Content-Location" should not exist
740748
And the JSON should be equal to:
741749
"""
742750
{

‎features/main/crud_abstract.feature

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Feature: Create-Retrieve-Update-Delete on abstract resource
3535
Then the response status code should be 200
3636
And the response should be in JSON
3737
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
38+
And the header "Content-Location" should not exist
3839
And the JSON should be equal to:
3940
"""
4041
{
@@ -52,6 +53,7 @@ Feature: Create-Retrieve-Update-Delete on abstract resource
5253
Then the response status code should be 200
5354
And the response should be in JSON
5455
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
56+
And the header "Content-Location" should not exist
5557
And the JSON should be valid according to this schema:
5658
"""
5759
{

‎features/main/crud_uri_variables.feature

+4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ Feature: Uri Variables
9696
Then the response status code should be 200
9797
And the response should be in JSON
9898
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
99+
And the header "Content-Location" should not exist
99100
And the JSON should be equal to:
100101
"""
101102
{
@@ -164,6 +165,7 @@ Feature: Uri Variables
164165
Then the response status code should be 200
165166
And the response should be in JSON
166167
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
168+
And the header "Content-Location" should not exist
167169
And the JSON should be equal to:
168170
"""
169171
{
@@ -183,6 +185,7 @@ Feature: Uri Variables
183185
Then the response status code should be 200
184186
And the response should be in JSON
185187
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
188+
And the header "Content-Location" should not exist
186189
And the JSON should be equal to:
187190
"""
188191
{
@@ -200,3 +203,4 @@ Feature: Uri Variables
200203
When I add "Content-Type" header equal to "application/ld+json"
201204
And I send a "GET" request to "/companies/1/employees/2"
202205
Then the response status code should be 404
206+
And the header "Content-Location" should not exist

‎src/State/Processor/RespondProcessor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
129129
$iri = $this->iriConverter->getIriFromResource($operation->getClass(), UrlGeneratorInterface::ABS_PATH, $operation);
130130
}
131131

132-
if ($iri) {
132+
if ($iri && 'GET' !== $method) {
133133
$location = \sprintf('%s.%s', $iri, $request->getRequestFormat());
134134
if (isset($requestParts['query'])) {
135135
$location .= '?'.$requestParts['query'];

0 commit comments

Comments
 (0)
Please sign in to comment.