Renault: fix retried request missing body (#11106)
This commit is contained in:
parent
3499d99e58
commit
e4af488a9c
1 changed files with 6 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package kamereon
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
|
@ -57,11 +58,14 @@ func (v *API) request_(uri string, body io.Reader) (Response, error) {
|
|||
}
|
||||
|
||||
func (v *API) request(uri string, body io.Reader) (Response, error) {
|
||||
res, err := v.request_(uri, body)
|
||||
var body2 bytes.Buffer
|
||||
body1 := io.TeeReader(body, &body2)
|
||||
|
||||
res, err := v.request_(uri, body1)
|
||||
// repeat auth if error
|
||||
if err != nil {
|
||||
if err = v.login(); err == nil {
|
||||
res, err = v.request_(uri, nil)
|
||||
res, err = v.request_(uri, &body2)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue