Renault: fix non-POST requests broken due to #11106
This commit is contained in:
parent
e4af488a9c
commit
19df92369e
1 changed files with 14 additions and 4 deletions
|
|
@ -58,14 +58,24 @@ func (v *API) request_(uri string, body io.Reader) (Response, error) {
|
|||
}
|
||||
|
||||
func (v *API) request(uri string, body io.Reader) (Response, error) {
|
||||
var body2 bytes.Buffer
|
||||
body1 := io.TeeReader(body, &body2)
|
||||
if body != nil {
|
||||
b, err := io.ReadAll(body)
|
||||
if err != nil {
|
||||
return Response{}, err
|
||||
}
|
||||
// read from buffer
|
||||
body = bytes.NewReader(b)
|
||||
}
|
||||
|
||||
res, err := v.request_(uri, body1)
|
||||
res, err := v.request_(uri, body)
|
||||
// repeat auth if error
|
||||
if err != nil {
|
||||
if err = v.login(); err == nil {
|
||||
res, err = v.request_(uri, &body2)
|
||||
if body != nil {
|
||||
// rewind body
|
||||
body.(*bytes.Reader).Seek(0, io.SeekStart)
|
||||
}
|
||||
res, err = v.request_(uri, body)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue