mirror of
https://github.com/1f349/site-hosting.git
synced 2025-04-14 07:36:05 +01:00
Only allow GET requests in the serve handler
This commit is contained in:
parent
f3c05c46a8
commit
3719fc57cc
@ -68,6 +68,11 @@ func cacheBuster(rw http.ResponseWriter, req *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
if req.Method != http.MethodGet {
|
||||||
|
http.Error(rw, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
host, _, err := net.SplitHostPort(req.Host)
|
host, _, err := net.SplitHostPort(req.Host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
host = req.Host
|
host = req.Host
|
||||||
|
@ -53,7 +53,7 @@ func serveTest(t *testing.T, address string, branch string, name string) {
|
|||||||
|
|
||||||
//goland:noinspection HttpUrlsUsage
|
//goland:noinspection HttpUrlsUsage
|
||||||
const httpPrefix = "http://"
|
const httpPrefix = "http://"
|
||||||
req := httptest.NewRequest(http.MethodPost, httpPrefix+address, nil)
|
req := httptest.NewRequest(http.MethodGet, httpPrefix+address, nil)
|
||||||
if branch != "" {
|
if branch != "" {
|
||||||
req.AddCookie(&http.Cookie{
|
req.AddCookie(&http.Cookie{
|
||||||
Name: "__bluebell-site-beta",
|
Name: "__bluebell-site-beta",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user