Skip to content

Commit e922d8e

Browse files
add 204 as a possible cors preflight response code (#4637)
A CORS preflight response has only headers, and some implementations use 204 No Content as the response code. This update adds 204 along with 200 as valid response codes for preflight requests. Change also regular (non preflight) responses to status code 200 only, since this is a response of a test backend configured by the conformance test. Co-authored-by: Joao Morais <jcmoraisjr@gmail.com>
1 parent 582fdbb commit e922d8e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

conformance/tests/httproute-cors.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ var HTTPRouteCORS = suite.ConformanceTest{
127127
},
128128
Namespace: "",
129129
Response: http.Response{
130-
StatusCode: 200,
130+
StatusCodes: []int{200, 204},
131131
ValidHeaderValues: map[string][]string{
132132
"access-control-allow-origin": {"https://www.bar.com"},
133133
"access-control-allow-methods": {
@@ -175,7 +175,7 @@ var HTTPRouteCORS = suite.ConformanceTest{
175175
},
176176
Namespace: "",
177177
Response: http.Response{
178-
StatusCode: 200,
178+
StatusCodes: []int{200, 204},
179179
ValidHeaderValues: map[string][]string{
180180
"access-control-allow-origin": {"https://xpto.www.bar.com"},
181181
"access-control-allow-methods": {
@@ -241,7 +241,7 @@ var HTTPRouteCORS = suite.ConformanceTest{
241241
},
242242
},
243243
Response: http.Response{
244-
StatusCodes: []int{200, 204},
244+
StatusCode: 200,
245245
Headers: map[string]string{
246246
"access-control-allow-origin": "https://www.foo.com",
247247
},
@@ -260,7 +260,7 @@ var HTTPRouteCORS = suite.ConformanceTest{
260260
},
261261
},
262262
Response: http.Response{
263-
StatusCodes: []int{200, 204},
263+
StatusCode: 200,
264264
Headers: map[string]string{
265265
"access-control-allow-origin": "https://www.bar.com",
266266
},
@@ -341,6 +341,7 @@ var HTTPRouteCORS = suite.ConformanceTest{
341341
},
342342
Namespace: "",
343343
Response: http.Response{
344+
StatusCodes: []int{200, 204},
344345
AbsentHeaders: []string{"Access-Control-Allow-Credentials"},
345346
},
346347
},
@@ -424,7 +425,7 @@ var HTTPRouteCORS = suite.ConformanceTest{
424425
},
425426
},
426427
Response: http.Response{
427-
StatusCodes: []int{200},
428+
StatusCode: 200,
428429
ValidHeaderValues: map[string][]string{
429430
// The access-control-allow-origin for a wildcard domain depends on the implementation.
430431
// Envoy enforces the return of the same requested Origin, while NGINX an others may return a "*"
@@ -448,7 +449,7 @@ var HTTPRouteCORS = suite.ConformanceTest{
448449
},
449450
},
450451
Response: http.Response{
451-
StatusCodes: []int{200, 204},
452+
StatusCode: 200,
452453
ValidHeaderValues: map[string][]string{
453454
// The access-control-allow-origin for a wildcard domain depends on the implementation.
454455
// Envoy enforces the return of the same requested Origin, while NGINX an others may return a "*"
@@ -488,7 +489,7 @@ var HTTPRouteCORS = suite.ConformanceTest{
488489
},
489490
Namespace: "",
490491
Response: http.Response{
491-
StatusCode: 200,
492+
StatusCodes: []int{200, 204},
492493
ValidHeaderValues: map[string][]string{
493494
"access-control-allow-origin": {"https://other.foo.com"},
494495
"access-control-allow-methods": {"PUT"},
@@ -528,7 +529,7 @@ var HTTPRouteCORS = suite.ConformanceTest{
528529
},
529530
Namespace: "",
530531
Response: http.Response{
531-
StatusCode: 200,
532+
StatusCodes: []int{200, 204},
532533
ValidHeaderValues: map[string][]string{
533534
"access-control-allow-origin": {"https://other.foo.com", "*"},
534535
"access-control-allow-methods": {

0 commit comments

Comments
 (0)