The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7069

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
And accept both quoted and unquoted values in If-Match.

Closes #7068

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 1698da3234bb17a8fbe5f2bf5fa306a6a31b0f3e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Sat, 21 Mar 2020 22:17:14 -0400
Subject: [PATCH] lxd/etag: Quote generated etag values
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

And accept both quoted and unquoted values in If-Match.

Closes #7068

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/response/response.go | 2 +-
 lxd/util/http.go         | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lxd/response/response.go b/lxd/response/response.go
index 128b1015d0..5270c489f3 100644
--- a/lxd/response/response.go
+++ b/lxd/response/response.go
@@ -74,7 +74,7 @@ func (r *syncResponse) Render(w http.ResponseWriter) error {
        if r.etag != nil {
                etag, err := util.EtagHash(r.etag)
                if err == nil {
-                       w.Header().Set("ETag", etag)
+                       w.Header().Set("ETag", fmt.Sprintf("\"%s\"", etag))
                }
        }
 
diff --git a/lxd/util/http.go b/lxd/util/http.go
index d2e16ea050..8b4d06c11e 100644
--- a/lxd/util/http.go
+++ b/lxd/util/http.go
@@ -64,6 +64,8 @@ func EtagCheck(r *http.Request, data interface{}) error {
                return nil
        }
 
+       match = strings.Trim(match, "\"")
+
        hash, err := EtagHash(data)
        if err != nil {
                return err
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to