1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-10-05 17:18:48 +00:00

httputil: Fixed JSON body not reusable

This commit is contained in:
diamondburned 2021-01-13 15:20:26 -08:00
parent d940a97a0f
commit de3049b730

View file

@ -81,11 +81,10 @@ func WithJSONBody(v interface{}) RequestOption {
return func(httpdriver.Request) error { return nil }
}
var rp, wp = io.Pipe()
go func() { wp.CloseWithError(json.EncodeStream(wp, v)) }()
return func(r httpdriver.Request) error {
rp, wp := io.Pipe()
go func() { wp.CloseWithError(json.EncodeStream(wp, v)) }()
r.AddHeader(http.Header{
"Content-Type": {"application/json"},
})