mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-03-23 18:39:35 +00:00
httputil: Fixed JSON body not reusable
This commit is contained in:
parent
d940a97a0f
commit
de3049b730
|
@ -81,11 +81,10 @@ func WithJSONBody(v interface{}) RequestOption {
|
||||||
return func(httpdriver.Request) error { return nil }
|
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 {
|
return func(r httpdriver.Request) error {
|
||||||
|
rp, wp := io.Pipe()
|
||||||
|
go func() { wp.CloseWithError(json.EncodeStream(wp, v)) }()
|
||||||
|
|
||||||
r.AddHeader(http.Header{
|
r.AddHeader(http.Header{
|
||||||
"Content-Type": {"application/json"},
|
"Content-Type": {"application/json"},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue