Hang in Post/Redirect/Get against Go server
Given this trivial Go server:
package main
import "net/http"
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
http.Redirect(w, r, "/", http.StatusSeeOther)
} else {
w.WriteHeader(http.StatusNoContent)
}
})
http.ListenAndServe(":1337", nil)
}
curl will succeed in following a post/redirect/get against it:
$ curl -d=foo -L -v http://localhost:1337
* Trying ::1:1337...
* Connected to localhost (::1) port 1337 (#0)
> POST / HTTP/1.1
> Host: localhost:1337
> User-Agent: curl/7.77.0
> Accept: */*
> Content-Length: 4
> Content-Type: application/x-www-form-urlencoded
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 303 See Other
< Location: /
< Date: Mon, 28 Jun 2021 18:21:56 GMT
< Content-Length: 0
<
* Connection #0 to host localhost left intact
* Issue another request to this URL: 'http://localhost:1337/'
* Switch to GET
* Found bundle for host localhost: 0x560893aba970 [serially]
* Can not multiplex, even if we wanted to!
* Re-using existing connection! (#0) with host localhost
* Connected to localhost (::1) port 1337 (#0)
> GET / HTTP/1.1
> Host: localhost:1337
> User-Agent: curl/7.77.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 204 No Content
< Date: Mon, 28 Jun 2021 18:21:56 GMT
<
* Connection #0 to host localhost left intact
rakurl with the exact same flags with hang:
$ rakurl -d=foo -L -v http://localhost:1337
> POST / HTTP/1.1
> Host: localhost:1337
> Content-Length: 4
> Content-Type: application/x-www-form-urlencoded
> User-Agent: HTTP::Tiny/0.1.8 Raku
>
< HTTP/1.1 303 See Other
< Location: /
< Date: Mon, 28 Jun 2021 18:21:38 GMT
< Content-Length: 0
<
> GET / HTTP/1.1
> Host: localhost:1337
> Content-Length: 4
> Content-Type: application/x-www-form-urlencoded
> User-Agent: HTTP::Tiny/0.1.8 Raku
>
^C
One difference is that curl doesn't preserve the request body across the redirect which might be related.
Edited by James Raspass