always stream decode json
parent
20aee9bf85
commit
f74a5435ca
|
@ -5,7 +5,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
@ -99,16 +98,12 @@ func (c *Client) Write(bp BatchPoints) (*Results, error) {
|
|||
defer resp.Body.Close()
|
||||
|
||||
var results Results
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
if len(body) > 0 {
|
||||
dec := json.NewDecoder(bytes.NewReader(body))
|
||||
dec := json.NewDecoder(resp.Body)
|
||||
dec.UseNumber()
|
||||
err = dec.Decode(&results)
|
||||
|
||||
if err != nil {
|
||||
if err != nil && err.Error() != "EOF" {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return &results, results.Error()
|
||||
|
|
Loading…
Reference in New Issue