diff options
author | am3o <2829-am3o@gitlab.torproject.org> | 2024-02-17 12:47:22 +0100 |
---|---|---|
committer | am3o <2829-am3o@gitlab.torproject.org> | 2024-02-17 12:47:22 +0100 |
commit | acce1f1fd90222008dae644fe4b4c07a8225057e (patch) | |
tree | 1d1e021ee305241b0447ea8a49c9e70b743ab852 /broker | |
parent | 35984c0876273adb810ab3cc558464ba786aafcd (diff) | |
download | snowflake-acce1f1fd90222008dae644fe4b4c07a8225057e.tar.gz snowflake-acce1f1fd90222008dae644fe4b4c07a8225057e.zip |
refactor: change deprecated "io/ioutil" package to recommended "io" package
Diffstat (limited to 'broker')
-rw-r--r-- | broker/http.go | 7 | ||||
-rw-r--r-- | broker/snowflake-broker_test.go | 7 |
2 files changed, 6 insertions, 8 deletions
diff --git a/broker/http.go b/broker/http.go index 2b68747..d1ba20d 100644 --- a/broker/http.go +++ b/broker/http.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "net/http" "os" @@ -94,7 +93,7 @@ func debugHandler(i *IPC, w http.ResponseWriter, r *http.Request) { For snowflake proxies to request a client from the Broker. */ func proxyPolls(i *IPC, w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(http.MaxBytesReader(w, r.Body, readLimit)) + body, err := io.ReadAll(http.MaxBytesReader(w, r.Body, readLimit)) if err != nil { log.Println("Invalid data.", err.Error()) w.WriteHeader(http.StatusBadRequest) @@ -132,7 +131,7 @@ snowflake proxy, which responds with the SDP answer to be sent in the HTTP response back to the client. */ func clientOffers(i *IPC, w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(http.MaxBytesReader(w, r.Body, readLimit)) + body, err := io.ReadAll(http.MaxBytesReader(w, r.Body, readLimit)) if err != nil { log.Printf("Error reading client request: %s", err.Error()) w.WriteHeader(http.StatusBadRequest) @@ -212,7 +211,7 @@ an offer from proxyHandler to respond with an answer in an HTTP POST, which the broker will pass back to the original client. */ func proxyAnswers(i *IPC, w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(http.MaxBytesReader(w, r.Body, readLimit)) + body, err := io.ReadAll(http.MaxBytesReader(w, r.Body, readLimit)) if err != nil { log.Println("Invalid data.", err.Error()) w.WriteHeader(http.StatusBadRequest) diff --git a/broker/snowflake-broker_test.go b/broker/snowflake-broker_test.go index 8179bb0..92d5700 100644 --- a/broker/snowflake-broker_test.go +++ b/broker/snowflake-broker_test.go @@ -6,7 +6,6 @@ import ( "encoding/hex" "fmt" "io" - "io/ioutil" "log" "net/http" "net/http/httptest" @@ -22,7 +21,7 @@ import ( func NullLogger() *log.Logger { logger := log.New(os.Stdout, "", 0) - logger.SetOutput(ioutil.Discard) + logger.SetOutput(io.Discard) return logger } @@ -78,7 +77,7 @@ func decodeAMPArmorToString(r io.Reader) (string, error) { if err != nil { return "", err } - p, err := ioutil.ReadAll(dec) + p, err := io.ReadAll(dec) return string(p), err } @@ -460,7 +459,7 @@ client-sqs-count 0 So(err, ShouldBeNil) proxyAnswers(i, w, r) So(w.Code, ShouldEqual, http.StatusOK) - b, err := ioutil.ReadAll(w.Body) + b, err := io.ReadAll(w.Body) So(err, ShouldBeNil) So(b, ShouldResemble, []byte(`{"Status":"client gone"}`)) }) |