From ef70ca9ec08c98cbb838ced2e8c43235998ab862 Mon Sep 17 00:00:00 2001 From: Patrick Dowler Date: Mon, 8 Apr 2024 15:16:29 -0700 Subject: [PATCH] vault:1.0.1 fix /files redirect http header --- vault/VERSION | 2 +- .../src/main/java/org/opencadc/vault/files/GetAction.java | 4 ++-- .../main/java/org/opencadc/vault/files/HeadAction.java | 8 +++++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/vault/VERSION b/vault/VERSION index 3d4fab56..7b280609 100644 --- a/vault/VERSION +++ b/vault/VERSION @@ -4,6 +4,6 @@ # tags with and without build number so operators use the versioned # tag but we always keep a timestamped tag in case a semantic tag gets # replaced accidentally -VER=1.0.0 +VER=1.0.1 TAGS="${VER} ${VER}-$(date --utc +"%Y%m%dT%H%M%S")" unset VER diff --git a/vault/src/main/java/org/opencadc/vault/files/GetAction.java b/vault/src/main/java/org/opencadc/vault/files/GetAction.java index 231cad51..bc5722ee 100644 --- a/vault/src/main/java/org/opencadc/vault/files/GetAction.java +++ b/vault/src/main/java/org/opencadc/vault/files/GetAction.java @@ -96,7 +96,8 @@ public GetAction() { @Override public void doAction() throws Exception { - DataNode node = resolveAndSetMetadata(); + // don't set content-length header since we plan to redirect + DataNode node = resolveAndSetMetadata(false); Subject caller = AuthenticationUtil.getCurrentSubject(); if (!voSpaceAuthorizer.hasSingleNodeReadPermission(node, caller)) { @@ -126,5 +127,4 @@ public void doAction() throws Exception { syncOutput.setHeader("Location", loc); syncOutput.setCode(HttpURLConnection.HTTP_SEE_OTHER); } - } diff --git a/vault/src/main/java/org/opencadc/vault/files/HeadAction.java b/vault/src/main/java/org/opencadc/vault/files/HeadAction.java index 902c4c9a..58a85b3f 100644 --- a/vault/src/main/java/org/opencadc/vault/files/HeadAction.java +++ b/vault/src/main/java/org/opencadc/vault/files/HeadAction.java @@ -132,10 +132,10 @@ public void initAction() throws Exception { @Override public void doAction() throws Exception { - resolveAndSetMetadata(); + resolveAndSetMetadata(true); } - DataNode resolveAndSetMetadata() throws Exception { + DataNode resolveAndSetMetadata(boolean includeContentLength) throws Exception { PathResolver pathResolver = new PathResolver(nodePersistence, voSpaceAuthorizer); String filePath = syncInput.getPath(); Node node = pathResolver.getNode(filePath, true); @@ -151,7 +151,9 @@ DataNode resolveAndSetMetadata() throws Exception { log.debug("node path resolved: " + node.getName() + " type: " + node.getClass().getName()); DataNode dn = (DataNode) node; - syncOutput.setHeader("Content-Length", dn.bytesUsed); + if (includeContentLength) { + syncOutput.setHeader("Content-Length", dn.bytesUsed); + } syncOutput.setHeader("Content-Disposition", "inline; filename=\"" + node.getName() + "\""); syncOutput.setHeader("Content-Type", node.getPropertyValue(VOS.PROPERTY_URI_TYPE)); syncOutput.setHeader("Content-Encoding", node.getPropertyValue(VOS.PROPERTY_URI_CONTENTENCODING));