Hi all,

Apologies if this has been discussed before.  I searched and didn't find 
anything.  There are a few places in http/server.go that will redirect with 
301s and that could cause clients, including Go's client, to change the 
method to a GET.  One place/condition when it does this kind of redirect is 
in ServeMux.Handler if the request has a double-slash in the path.  This 
could be problematic if the request is doing a non-GET request such as a 
POST.

Here's an easy way to reproduce what I'm talking about:

package main


import (

        "fmt"

        "net/http"

)

 

func main() {

        http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {

                fmt.Fprintf(w, "Hello, World!")

        })

        http.ListenAndServe(":8080", nil)

}


Then "curl -X POST http://localhost//"; which result result in a 301.  I 
propose that this should result in a 308 instead of a 301 so clients 
(including Go's http client) won't change the method to GET when handling 
the redirect.  I encountered this in the project I'm working on because we 
accidentally were making a request like "POST http://<server>//api/<path>" 
using a Go client and talking to a Go server.  I was going to file a bug on 
this but wanted to consult this list first.


Regards,

-Rob

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/d8cd6c54-33f0-45bc-b368-eb336e12e3e5%40googlegroups.com.

Reply via email to