Skip to content

Commit

Permalink
vault:1.0.1 fix /files redirect http header
Browse files Browse the repository at this point in the history
  • Loading branch information
pdowler committed Apr 8, 2024
1 parent d3d5e12 commit ef70ca9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion vault/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions vault/src/main/java/org/opencadc/vault/files/GetAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -126,5 +127,4 @@ public void doAction() throws Exception {
syncOutput.setHeader("Location", loc);
syncOutput.setCode(HttpURLConnection.HTTP_SEE_OTHER);
}

}
8 changes: 5 additions & 3 deletions vault/src/main/java/org/opencadc/vault/files/HeadAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
Expand Down

0 comments on commit ef70ca9

Please sign in to comment.