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 

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

package main

import (





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.



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 

Reply via email to