mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 21:01:31 +00:00
Fix regression caused by commit ad65479
Commitad65479
will cause "Method Not Allow" in preflight response when enable CORS plugin. The root cause is that CORS plugin didn't generate http output after applied commitad65479
, so the value of `ctx.ResponseWriter.Started` will be keep `false`, and then later filter chains will be go on to run when CORS filter finished. This path will both fix "Method Not Allow" and the original bug "multiple response.WriteHeader calls". Signed-off-by: Yunkai Zhang <qiushu.zyk@taobao.com>
This commit is contained in:
parent
23bb36d35c
commit
e3810b599d
@ -36,6 +36,7 @@
|
|||||||
package cors
|
package cors
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -215,6 +216,7 @@ func Allow(opts *Options) beego.FilterFunc {
|
|||||||
for key, value := range headers {
|
for key, value := range headers {
|
||||||
ctx.Output.Header(key, value)
|
ctx.Output.Header(key, value)
|
||||||
}
|
}
|
||||||
|
ctx.ResponseWriter.WriteHeader(http.StatusOK)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
headers = opts.Header(origin)
|
headers = opts.Header(origin)
|
||||||
|
Loading…
Reference in New Issue
Block a user