Skip to content

Commit 5e95196

Browse files
tommysituJohnFDavenport
authored andcommitted
Fix a typo in a CORS header
1 parent be1db66 commit 5e95196

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

core/cors/cors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func DefaultCORSConfigs() *Configs {
3232
// TODO provide config to pass through OPTIONS call
3333
// Intercept pre-flight request and return 200 response with CORS headers
3434
func (c *Configs) InterceptPreflightRequest(r *http.Request) *http.Response {
35-
if r.Method != http.MethodOptions || r.Header.Get("Origin") == "" || r.Header.Get("Access-Control-Request-Methods") == "" {
35+
if r.Method != http.MethodOptions || r.Header.Get("Origin") == "" || r.Header.Get("Access-Control-Request-Method") == "" {
3636
return nil
3737
}
3838
resp := &http.Response{}

core/cors/cors_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func Test_InterceptPreflightRequest_ReturnSuccessResponseWithDefaultHeaders(t *t
1515
r, err := http.NewRequest(http.MethodOptions, "http://somehost.com", nil)
1616
Expect(err).To(BeNil())
1717
r.Header.Set("Origin", "http://originhost.com")
18-
r.Header.Set("Access-Control-Request-Methods", "PUT,POST")
18+
r.Header.Set("Access-Control-Request-Method", "PUT")
1919
resp := unit.InterceptPreflightRequest(r)
2020

2121
Expect(resp).ToNot(BeNil())
@@ -37,7 +37,7 @@ func Test_InterceptPreflightRequest_ReturnNilIfRequestIsNotOptions(t *testing.T)
3737
r, err := http.NewRequest(http.MethodGet, "http://somehost.com", nil)
3838
Expect(err).To(BeNil())
3939
r.Header.Set("Origin", "http://originhost.com")
40-
r.Header.Set("Access-Control-Request-Methods", "PUT,POST")
40+
r.Header.Set("Access-Control-Request-Method", "PUT")
4141
resp := unit.InterceptPreflightRequest(r)
4242

4343
Expect(resp).To(BeNil())
@@ -50,7 +50,7 @@ func Test_InterceptPreflightRequest_ReturnNilIfRequestHasNoOriginHeader(t *testi
5050

5151
r, err := http.NewRequest(http.MethodOptions, "http://somehost.com", nil)
5252
Expect(err).To(BeNil())
53-
r.Header.Set("Access-Control-Request-Methods", "PUT,POST")
53+
r.Header.Set("Access-Control-Request-Method", "PUT")
5454
resp := unit.InterceptPreflightRequest(r)
5555

5656
Expect(resp).To(BeNil())
@@ -77,7 +77,7 @@ func Test_InterceptPreflightRequest_ShouldEchoAllowHeaders(t *testing.T) {
7777
r, err := http.NewRequest(http.MethodOptions, "http://somehost.com", nil)
7878
Expect(err).To(BeNil())
7979
r.Header.Set("Origin", "http://originhost.com")
80-
r.Header.Set("Access-Control-Request-Methods", "PUT,POST")
80+
r.Header.Set("Access-Control-Request-Method", "PUT")
8181
r.Header.Set("Access-Control-Request-Headers", "X-PINGOTHER,Content-Type")
8282
resp := unit.InterceptPreflightRequest(r)
8383

@@ -95,7 +95,7 @@ func Test_InterceptPreflightRequest_ShouldNotSetAllowCredentialsHeaderIfFalse(t
9595
r, err := http.NewRequest(http.MethodOptions, "http://somehost.com", nil)
9696
Expect(err).To(BeNil())
9797
r.Header.Set("Origin", "http://originhost.com")
98-
r.Header.Set("Access-Control-Request-Methods", "PUT,POST")
98+
r.Header.Set("Access-Control-Request-Method", "PUT")
9999
resp := unit.InterceptPreflightRequest(r)
100100

101101
Expect(resp).ToNot(BeNil())
@@ -112,7 +112,7 @@ func Test_InterceptPreflightRequest_UseDefaultAllowOriginValueIfAllowCredentials
112112
r, err := http.NewRequest(http.MethodOptions, "http://somehost.com", nil)
113113
Expect(err).To(BeNil())
114114
r.Header.Set("Origin", "http://originhost.com")
115-
r.Header.Set("Access-Control-Request-Methods", "PUT,POST")
115+
r.Header.Set("Access-Control-Request-Method", "PUT")
116116
resp := unit.InterceptPreflightRequest(r)
117117

118118
Expect(resp).ToNot(BeNil())

core/hoverfly_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ func Test_Hoverfly_processRequest_CanHandlePreflightRequestWhenCORSEnabled(t *te
564564
r, err := http.NewRequest(http.MethodOptions, "http://somehost.com", nil)
565565
Expect(err).To(BeNil())
566566
r.Header.Set("Origin", "http://originhost.com")
567-
r.Header.Set("Access-Control-Request-Methods", "PUT,POST")
567+
r.Header.Set("Access-Control-Request-Method", "PUT")
568568
r.Header.Set("Access-Control-Request-Headers", "X-PINGOTHER,Content-Type")
569569

570570
unit.Cfg.CORS = *cors.DefaultCORSConfigs()

functional-tests/core/ft_cors_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var _ = Describe("When I run Hoverfly", func() {
4141
fakeServer.StartTLS()
4242
defer fakeServer.Close()
4343

44-
resp := hoverfly.Proxy(sling.New().Options(fakeServer.URL).Add("Origin", "http://some-host.com").Add("Access-Control-Request-Methods", "POST"))
44+
resp := hoverfly.Proxy(sling.New().Options(fakeServer.URL).Add("Origin", "http://some-host.com").Add("Access-Control-Request-Method", "POST"))
4545
Expect(resp.StatusCode).To(Equal(200))
4646
Expect(resp.Header.Get("Access-Control-Allow-Origin")).To(Equal("http://some-host.com"))
4747
Expect(resp.Header.Get("Access-Control-Allow-Methods")).To(Equal("GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS"))

0 commit comments

Comments
 (0)