File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -104,10 +104,14 @@ func TestCors(t *testing.T) {
104
104
// Should always set some kind of allowed origin, if allowed.
105
105
require .Equal (t , test .allowedOrigin , rw .Header ().Get (httpmw .AccessControlAllowOriginHeader ))
106
106
107
- // OPTIONS should echo back the request method and headers and we
108
- // should never get to our handler as the middleware short-circuits
109
- // with a 200.
110
- if method == http .MethodOptions {
107
+ // OPTIONS should echo back the request method and headers (if there
108
+ // is an origin header set) and we should never get to our handler as
109
+ // the middleware short-circuits with a 200.
110
+ if method == http .MethodOptions && test .origin == "" {
111
+ require .Equal (t , "" , rw .Header ().Get (httpmw .AccessControlAllowMethodsHeader ))
112
+ require .Equal (t , "" , rw .Header ().Get (httpmw .AccessControlAllowHeadersHeader ))
113
+ require .Equal (t , http .StatusOK , rw .Code )
114
+ } else if method == http .MethodOptions {
111
115
require .Equal (t , http .MethodGet , rw .Header ().Get (httpmw .AccessControlAllowMethodsHeader ))
112
116
require .Equal (t , test .allowedHeaders , rw .Header ().Get (httpmw .AccessControlAllowHeadersHeader ))
113
117
require .Equal (t , http .StatusOK , rw .Code )
You can’t perform that action at this time.
0 commit comments