diff --git a/delugeclient.go b/delugeclient.go
index <HASH>..<HASH> 100644
--- a/delugeclient.go
+++ b/delugeclient.go
@@ -366,7 +366,13 @@ func (c *Client) rpc(methodName string, args rencode.List, kwargs rencode.Dictio
 		return nil, err
 	}
 
-	d := rencode.NewDecoder(zr)
+	// buffered input here is necessary to avoid the rencode decoder racing past the ZLib decoder
+	var deflatedBuf bytes.Buffer
+	_, err = io.Copy(&deflatedBuf, zr)
+	if err != nil {
+		return nil, err
+	}
+	d := rencode.NewDecoder(&deflatedBuf)
 
 	resp, err := c.handleRpcResponse(d, c.serial)
 	if err != nil {
Deflate in a buffer to avoid too early rencode decoding

Fixes #<I>