mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
change: replace ioutil.ReadAll with io.ReadAll
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -176,7 +176,7 @@ func (g *GA4Client) SendEvent(event Event) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
bs, err = ioutil.ReadAll(res.Body)
|
bs, err = io.ReadAll(res.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "read GA4 response body failed")
|
return errors.Wrap(err, "read GA4 response body failed")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package gadb
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -97,7 +96,7 @@ func (t transport) ReadStringAll() (s string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t transport) ReadBytesAll() (raw []byte, err error) {
|
func (t transport) ReadBytesAll() (raw []byte, err error) {
|
||||||
raw, err = ioutil.ReadAll(t.sock)
|
raw, err = io.ReadAll(t.sock)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -109,7 +108,7 @@ func (c *PcapdClient) GetPacket(buf []byte) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
packet, err := ioutil.ReadAll(preader)
|
packet, err := io.ReadAll(preader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return packet, err
|
return packet, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ func (wd *Driver) httpRequest(method string, rawURL string, rawBody []byte) (raw
|
|||||||
_ = resp.Body.Close()
|
_ = resp.Body.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
rawResp, err = ioutil.ReadAll(resp.Body)
|
rawResp, err = io.ReadAll(resp.Body)
|
||||||
logger := log.Debug().Int("statusCode", resp.StatusCode).Str("duration", time.Since(start).String())
|
logger := log.Debug().Int("statusCode", resp.StatusCode).Str("duration", time.Since(start).String())
|
||||||
if !strings.HasSuffix(rawURL, "screenshot") {
|
if !strings.HasSuffix(rawURL, "screenshot") {
|
||||||
// avoid printing screenshot data
|
// avoid printing screenshot data
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ func getBufFromDisk(name string) (*bytes.Buffer, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var all []byte
|
var all []byte
|
||||||
if all, err = ioutil.ReadAll(f); err != nil {
|
if all, err = io.ReadAll(f); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return bytes.NewBuffer(all), nil
|
return bytes.NewBuffer(all), nil
|
||||||
@@ -361,7 +361,7 @@ func getMatsFromDisk(nameImage, nameTpl string, flags gocv.IMReadFlag) (matImage
|
|||||||
// return nil, e
|
// return nil, e
|
||||||
// }
|
// }
|
||||||
// var all []byte
|
// var all []byte
|
||||||
// if all, e = ioutil.ReadAll(f); e != nil {
|
// if all, e = io.ReadAll(f); e != nil {
|
||||||
// return nil, e
|
// return nil, e
|
||||||
// }
|
// }
|
||||||
// return bytes.NewBuffer(all), nil
|
// return bytes.NewBuffer(all), nil
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -42,7 +42,7 @@ func parseBody(r *http.Request) (data map[string]interface{}, err error) {
|
|||||||
|
|
||||||
// Always set resp.Data to the incoming request body, in case we don't know
|
// Always set resp.Data to the incoming request body, in case we don't know
|
||||||
// how to handle the content type
|
// how to handle the content type
|
||||||
body, err := ioutil.ReadAll(r.Body)
|
body, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
r.Body.Close()
|
r.Body.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user