From e5e121a6b19cccc92e6e31459e14412a3023fac1 Mon Sep 17 00:00:00 2001
From: Matt Bell <mappum@gmail.com>
Date: Wed, 15 Oct 2014 21:20:33 -0700
Subject: [PATCH] commands: Made Request#Option also return an existence bool

---
 commands/request.go  | 5 +++--
 commands/response.go | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/commands/request.go b/commands/request.go
index 42e9ec0e3..b8025a6b3 100644
--- a/commands/request.go
+++ b/commands/request.go
@@ -21,8 +21,9 @@ func (r *Request) SetPath(path []string) {
 	r.path = path
 }
 
-func (r *Request) Option(name string) interface{} {
-	return r.options[name]
+func (r *Request) Option(name string) (interface{}, bool) {
+	val, ok := r.options[name]
+	return val, ok
 }
 
 func (r *Request) SetOption(name string, value interface{}) {
diff --git a/commands/response.go b/commands/response.go
index 6edaf1a59..0791a31a2 100644
--- a/commands/response.go
+++ b/commands/response.go
@@ -57,8 +57,8 @@ func (r *Response) Marshal() ([]byte, error) {
 		return nil, fmt.Errorf("No error or value set, there is nothing to marshal")
 	}
 
-	enc := r.req.Option("enc")
-	if enc == nil {
+	enc, ok := r.req.Option("enc")
+	if !ok || enc.(string) == "" {
 		return nil, fmt.Errorf("No encoding type was specified")
 	}
 	encType := EncodingType(strings.ToLower(enc.(string)))
-- 
GitLab