Merge branch '5011-thread-safe-test' refs #5011
[arvados.git] / services / keepstore / handlers.go
index 7e4256ff135c85189e592bba5486a2fbf29f241c..c7559a1bee313783372cfa9e88f918618459dae5 100644 (file)
@@ -171,14 +171,11 @@ func GetBlockHandler(resp http.ResponseWriter, req *http.Request) {
        if err != nil {
                // This type assertion is safe because the only errors
                // GetBlock can return are DiskHashError or NotFoundError.
-               if err == NotFoundError {
-                       log.Printf("%s: not found, giving up\n", hash)
-               }
                http.Error(resp, err.Error(), err.(*KeepError).HTTPCode)
                return
        }
 
-       resp.Header().Set("X-Block-Size", fmt.Sprintf("%d", len(block)))
+       resp.Header().Set("Content-Length", fmt.Sprintf("%d", len(block)))
 
        _, err = resp.Write(block)
 
@@ -348,7 +345,6 @@ func GetVolumeStatus(volume string) *VolumeStatus {
 //
 func DeleteHandler(resp http.ResponseWriter, req *http.Request) {
        hash := mux.Vars(req)["hash"]
-       log.Printf("%s %s", req.Method, hash)
 
        // Confirm that this user is an admin and has a token with unlimited scope.
        var tok = GetApiToken(req)
@@ -732,38 +728,3 @@ func CanDelete(api_token string) bool {
 func IsDataManagerToken(api_token string) bool {
        return data_manager_token != "" && api_token == data_manager_token
 }
-
-type LoggingResponseWriter struct {
-  status int
-  data []byte
-  http.ResponseWriter
-}
-
-func (loggingWriter *LoggingResponseWriter) WriteHeader(code int) {
-  loggingWriter.status = code
-  loggingWriter.ResponseWriter.WriteHeader(code)
-}
-
-func (loggingWriter *LoggingResponseWriter) Write(data []byte) (int, error){
-  loggingWriter.data = data
-  return loggingWriter.ResponseWriter.Write(data)
-}
-
-type WrapRESTRouter struct {
-  router *mux.Router
-}
-
-func (wrapper *WrapRESTRouter) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
-  loggingWriter := LoggingResponseWriter{200, nil, resp}
-  wrapper.router.ServeHTTP(&loggingWriter, req)
-  if loggingWriter.data != nil && loggingWriter.status == 200 {
-    data_len := len(loggingWriter.data)
-    if data_len > 200 {  // this could be a block, so just print the size
-      log.Printf("[%s] %s %s %d %d", req.RemoteAddr, req.Method, req.URL.Path[1:], loggingWriter.status, data_len)
-    } else {  // this could be a hash or status or a small block etc
-      log.Printf("[%s] %s %s %d %s", req.RemoteAddr, req.Method, req.URL.Path[1:], loggingWriter.status, loggingWriter.data)
-    }
-  } else {
-    log.Printf("[%s] %s %s %d", req.RemoteAddr, req.Method, req.URL.Path[1:], loggingWriter.status)
-  }
-}