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