Skip to content

Commit

Permalink
refac(pkg): remove deprecated package
Browse files Browse the repository at this point in the history
  • Loading branch information
mitch000001 committed Mar 2, 2024
1 parent 2d72504 commit b471743
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 25 deletions.
4 changes: 2 additions & 2 deletions dialog/dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bufio"
"bytes"
"fmt"
"io/ioutil"
"io"
"log"
"net"
"strconv"
Expand Down Expand Up @@ -587,7 +587,7 @@ func (d *dialog) request(clientMessage message.ClientMessage) (message.BankMessa

request := &transport.Request{
URL: d.hbciURL,
Body: ioutil.NopCloser(reqBody),
Body: io.NopCloser(reqBody),
}

response, err := d.transport.Do(request)
Expand Down
3 changes: 1 addition & 2 deletions transport/https/https.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/base64"
"io"
"io/ioutil"
"net/http"

"github.com/mitch000001/go-hbci/transport"
Expand Down Expand Up @@ -56,7 +55,7 @@ func (h *HTTPSBase64Transport) Do(request *transport.Request) (*transport.Respon
} else {
reader = httpResponse.Body
}
return &transport.Response{Body: ioutil.NopCloser(reader), Request: request}, nil
return &transport.Response{Body: io.NopCloser(reader), Request: request}, nil
}

// New returns a HTTPSTransport. It sets http.DefaultClient as http.Client to
Expand Down
5 changes: 2 additions & 3 deletions transport/https/https_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/base64"
"io"
"io/ioutil"
"net/http"
"strings"
"testing"
Expand All @@ -27,12 +26,12 @@ func TestHttpsBase64Transport(t *testing.T) {

httpReq := &transport.Request{
URL: "foo",
Body: ioutil.NopCloser(strings.NewReader("bar")),
Body: io.NopCloser(strings.NewReader("bar")),
}

httpBase64Req := &transport.Request{
URL: "foo",
Body: ioutil.NopCloser(strings.NewReader("bar")),
Body: io.NopCloser(strings.NewReader("bar")),
}

httpResponse, httpError := httpsTransport.Do(httpReq)
Expand Down
5 changes: 2 additions & 3 deletions transport/https/mock_http_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"net/http"
"strings"
)
Expand Down Expand Up @@ -40,7 +39,7 @@ func (m *MockHTTPTransport) SetResponsePayload(payload []byte) int {
encodedMessage := base64.StdEncoding.EncodeToString(payload)
reader := strings.NewReader(encodedMessage)
m.responses = append(m.responses, &http.Response{
Body: ioutil.NopCloser(reader),
Body: io.NopCloser(reader),
ContentLength: int64(len(payload)),
Status: "200 OK",
StatusCode: 200,
Expand All @@ -64,7 +63,7 @@ func (m *MockHTTPTransport) SetResponsePayloads(payloads [][]byte) {
encodedMessage := base64.StdEncoding.EncodeToString(payload)
reader := strings.NewReader(encodedMessage)
m.responses[i] = &http.Response{
Body: ioutil.NopCloser(reader),
Body: io.NopCloser(reader),
ContentLength: int64(len(payload)),
Status: "200 OK",
StatusCode: 200,
Expand Down
9 changes: 4 additions & 5 deletions transport/middleware/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/base64"
"io"
"io/ioutil"

"github.com/mitch000001/go-hbci/transport"

Expand All @@ -26,14 +25,14 @@ func UTF8Encoding(encoding encoding.Encoding) transport.Middleware {
return nil, err
}
encodedRequest := req
encodedRequest.Body = ioutil.NopCloser(&buf)
encodedRequest.Body = io.NopCloser(&buf)
response, err := t.Do(encodedRequest)
if err != nil {
return nil, err
}
decodingReader := encoding.NewDecoder().Reader(response.Body)
decodedResponse := response
decodedResponse.Body = ioutil.NopCloser(decodingReader)
decodedResponse.Body = io.NopCloser(decodingReader)
return decodedResponse, nil
})
}
Expand All @@ -58,14 +57,14 @@ func Base64Encoding(encoding *base64.Encoding) transport.Middleware {
return nil, err
}
encodedRequest := req
encodedRequest.Body = ioutil.NopCloser(&buf)
encodedRequest.Body = io.NopCloser(&buf)
response, err := t.Do(encodedRequest)
if err != nil {
return nil, err
}
decodingReader := base64.NewDecoder(encoding, response.Body)
decodedResponse := response
decodedResponse.Body = ioutil.NopCloser(decodingReader)
decodedResponse.Body = io.NopCloser(decodingReader)
return decodedResponse, nil
})
}
Expand Down
9 changes: 4 additions & 5 deletions transport/middleware/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/base64"
"io"
"io/ioutil"
"reflect"
"strings"
"testing"
Expand Down Expand Up @@ -47,7 +46,7 @@ func (m *mockTransform) Reset() {

func TestUTF8Encoding(t *testing.T) {
called := false
transportResponse := transport.Response{Body: ioutil.NopCloser(strings.NewReader("qux"))}
transportResponse := transport.Response{Body: io.NopCloser(strings.NewReader("qux"))}
var transportRequest *transport.Request
innerTransport := transport.Func(func(req *transport.Request) (*transport.Response, error) {
called = true
Expand All @@ -72,7 +71,7 @@ func TestUTF8Encoding(t *testing.T) {

request := &transport.Request{
URL: "foo",
Body: ioutil.NopCloser(strings.NewReader("bar")),
Body: io.NopCloser(strings.NewReader("bar")),
}

response, err := wrappedTransport.Do(request)
Expand Down Expand Up @@ -143,7 +142,7 @@ func TestBase64Encoding(t *testing.T) {

called := false
transportResponse := transport.Response{
Body: ioutil.NopCloser(strings.NewReader(encoding.EncodeToString([]byte("qux")))),
Body: io.NopCloser(strings.NewReader(encoding.EncodeToString([]byte("qux")))),
}
var transportRequest *transport.Request
innerTransport := transport.Func(func(req *transport.Request) (*transport.Response, error) {
Expand All @@ -159,7 +158,7 @@ func TestBase64Encoding(t *testing.T) {

request := &transport.Request{
URL: "foo",
Body: ioutil.NopCloser(strings.NewReader("bar")),
Body: io.NopCloser(strings.NewReader("bar")),
}

response, _ := wrappedTransport.Do(request)
Expand Down
5 changes: 2 additions & 3 deletions transport/middleware/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"log"
"strings"

Expand All @@ -28,7 +27,7 @@ func Logging(logger *log.Logger, cryptoProvider message.CryptoProvider) transpor
if err != nil {
logger.Printf("Error reading request body: %v", err)
}
req.Body = ioutil.NopCloser(&buf)
req.Body = io.NopCloser(&buf)
logger.Println("Decrypted Request:")
if err := writeMessage(cryptoProvider, logger.Writer(), marshaledRequest); err != nil {
logger.Printf("%s\n", marshaledRequest)
Expand All @@ -44,7 +43,7 @@ func Logging(logger *log.Logger, cryptoProvider message.CryptoProvider) transpor
if err != nil {
logger.Printf("Error reading response body: %v", err)
}
res.Body = ioutil.NopCloser(&responseBuf)
res.Body = io.NopCloser(&responseBuf)
logger.Println("Decrypted Response:")
if err := writeMessage(cryptoProvider, logger.Writer(), marshaledResponse); err != nil {
logger.Printf("%s\n", marshaledResponse)
Expand Down
3 changes: 1 addition & 2 deletions transport/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"bytes"
"io"
"io/ioutil"

"github.com/mitch000001/go-hbci/message"
"github.com/mitch000001/go-hbci/segment"
Expand Down Expand Up @@ -59,7 +58,7 @@ func ReadResponse(r *bufio.Reader, req *Request) (*Response, error) {
Request: req,
MarshaledResponse: marshaledMessage,
SegmentExtractor: extractor,
Body: ioutil.NopCloser(&buf),
Body: io.NopCloser(&buf),
}
return response, nil
}
Expand Down

0 comments on commit b471743

Please sign in to comment.