Skip to content

Commit 5b4806e

Browse files
committed
smallnest#212 remove duplicated unzip
1 parent a77f4a0 commit 5b4806e

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

client/client.go

-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/smallnest/rpcx/log"
1818
"github.com/smallnest/rpcx/protocol"
1919
"github.com/smallnest/rpcx/share"
20-
"github.com/smallnest/rpcx/util"
2120
)
2221

2322
const (
@@ -530,13 +529,6 @@ func (client *Client) input() {
530529
} else {
531530
data := res.Payload
532531
if len(data) > 0 {
533-
if res.CompressType() == protocol.Gzip {
534-
data, err = util.Unzip(data)
535-
if err != nil {
536-
call.Error = ServiceError("unzip payload: " + err.Error())
537-
}
538-
}
539-
540532
codec := share.Codecs[res.SerializeType()]
541533
if codec == nil {
542534
call.Error = ServiceError(ErrUnsupportedCodec.Error())

protocol/compressor.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package protocol
22

3-
import "github.com/smallnest/rpcx/util"
3+
import (
4+
"github.com/smallnest/rpcx/util"
5+
)
46

57
// Compressor defines a common compression interface.
68
type Compressor interface {

protocol/message.go

-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ func (m Message) Encode() []byte {
234234
payload = m.Payload
235235
}
236236
}
237-
238237
}
239238

240239
totalL := (4 + spL) + (4 + smL) + (4 + len(meta)) + (4 + len(payload))

server/server.go

+3
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ func (s *Server) serveConn(conn net.Conn) {
366366
}
367367
}
368368

369+
if len(res.Payload) > 1024 && req.CompressType() != protocol.None {
370+
res.SetCompressType(req.CompressType())
371+
}
369372
data := res.Encode()
370373
conn.Write(data)
371374
//res.WriteTo(conn)

0 commit comments

Comments
 (0)