[ARVADOS] created: 5cdf402cfc23ad287f1570b9db19a72a64b91fdc

git at public.curoverse.com git at public.curoverse.com
Sat May 24 14:37:12 EDT 2014


        at  5cdf402cfc23ad287f1570b9db19a72a64b91fdc (commit)


commit 5cdf402cfc23ad287f1570b9db19a72a64b91fdc
Author: Tim Pierce <twp at curoverse.com>
Date:   Sat May 24 14:34:45 2014 -0400

    2829: add X-Block-Size response header
    
    Responses to successful GET or HEAD requests include an X-Block-Size
    header.

diff --git a/services/keep/src/keep/handler_test.go b/services/keep/src/keep/handler_test.go
index 8e7bfea..c25b80d 100644
--- a/services/keep/src/keep/handler_test.go
+++ b/services/keep/src/keep/handler_test.go
@@ -11,6 +11,7 @@ package main
 
 import (
 	"bytes"
+	"fmt"
 	"github.com/gorilla/mux"
 	"net/http"
 	"net/http/httptest"
@@ -81,6 +82,11 @@ func TestGetHandler(t *testing.T) {
 		"Unauthenticated request, unsigned locator",
 		string(TEST_BLOCK),
 		response)
+	received_xbs := response.Header().Get("X-Block-Size")
+	expected_xbs := fmt.Sprintf("%d", len(TEST_BLOCK))
+	if received_xbs != expected_xbs {
+		t.Errorf("expected X-Block-Size %s, got %s", expected_xbs, received_xbs)
+	}
 
 	// ----------------
 	// Permissions: on.
@@ -97,6 +103,11 @@ func TestGetHandler(t *testing.T) {
 		"Authenticated request, signed locator", http.StatusOK, response)
 	ExpectBody(t,
 		"Authenticated request, signed locator", string(TEST_BLOCK), response)
+	received_xbs = response.Header().Get("X-Block-Size")
+	expected_xbs = fmt.Sprintf("%d", len(TEST_BLOCK))
+	if received_xbs != expected_xbs {
+		t.Errorf("expected X-Block-Size %s, got %s", expected_xbs, received_xbs)
+	}
 
 	// Authenticated request, unsigned locator
 	// => PermissionError
diff --git a/services/keep/src/keep/keep.go b/services/keep/src/keep/keep.go
index d65e445..001e66e 100644
--- a/services/keep/src/keep/keep.go
+++ b/services/keep/src/keep/keep.go
@@ -359,6 +359,8 @@ func GetBlockHandler(resp http.ResponseWriter, req *http.Request) {
 		return
 	}
 
+	resp.Header().Set("X-Block-Size", fmt.Sprintf("%d", len(block)))
+
 	_, err = resp.Write(block)
 	if err != nil {
 		log.Printf("GetBlockHandler: writing response: %s", err)

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list