Skip to content

Commit

Permalink
FET: Support generic readers that have the len interface
Browse files Browse the repository at this point in the history
  • Loading branch information
akissa committed Feb 1, 2022
1 parent 07edc4c commit c7fe9ba
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions sssp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ SSSP - Golang SSSP protocol implementation
package sssp

import (
"bytes"
"context"
"fmt"
"io"
Expand Down Expand Up @@ -65,6 +64,10 @@ var (
responseRe = regexp.MustCompile(`^VIRUS\s(?P<signature>\S+)\s(?P<filename>\S+)?$`)
)

type readerWithLen interface {
Len() int
}

// A Command represents a SSSP Command
type Command int

Expand Down Expand Up @@ -239,11 +242,7 @@ func (c *Client) readerCmd(i io.Reader) (r *Response, err error) {
defer c.conn.SetDeadline(ZeroTime)

switch v := i.(type) {
case *bytes.Buffer:
clen = int64(v.Len())
case *bytes.Reader:
clen = int64(v.Len())
case *strings.Reader:
case readerWithLen:
clen = int64(v.Len())
case *os.File:
stat, err = v.Stat()
Expand Down

0 comments on commit c7fe9ba

Please sign in to comment.