Skip to content

Commit

Permalink
## Description of Changes
Browse files Browse the repository at this point in the history
re: Issue

The DAP4 code was improperly handling the use of the "dap4:"
protocol in a url. This PR fixes it by detecting that protocol
and doing two actions:
1. Convert the protocol to "https:".
2. Add the fragment "#dap4" to end of the url.

Note that in \Unidata#1, this should really be https, but
test.opendap.org still uses http; one hopes that other servers
are setup to redirect http: to https:

## PR Checklist
<!-- This will become an interactive checklist once the PR is opened -->
- [X] Link to any issues that the PR addresses
- [X] Add labels
- [X] Open as a [draft PR](https://github.blog/2019-02-14-introducing-draft-pull-requests/) until ready for review
- [X] Make sure GitHub tests pass
- [X] Mark PR as "Ready for Review"
  • Loading branch information
DennisHeimbigner committed Nov 4, 2023
1 parent 027414a commit cdd73b0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 0 additions & 2 deletions dap4/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ test {
include 'dap4/test/TestParserCE.class'
include 'dap4/test/TestRaw.class'
include 'dap4/test/TestDap4Url.class'
if(false) { // disable selected dap4 tests for now
include 'dap4/test/TestRemote.class'
include 'dap4/test/TestConstraints.class'
include 'dap4/test/TestHyrax.class'
}

dependsOn('farmBeforeIntegrationTest')
finalizedBy('farmAfterIntegrationTest')
Expand Down
13 changes: 13 additions & 0 deletions dap4/src/main/java/dap4/core/util/XURI.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,19 @@ public void insertQueryField(String key, String newval) {
rebuildQuery();
}

/**
* Allow fragment fields to be inserted
*
* @param key
* @param newval
* @return previous value or this value if key not set
*/
public void insertFragmentField(String key, String newval) {
// Watch out in case there is no query
this.fragfields = insertAmpField(key, newval, parent.getFragment());
rebuildQuery();
}

/**
* Allow queryfields to be removed
*
Expand Down
7 changes: 7 additions & 0 deletions dap4/src/main/java/dap4/dap4lib/cdm/nc2/DapNetcdfFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ public DapNetcdfFile(String location, CancelTask cancelTask) throws IOException
} catch (URISyntaxException use) {
throw new IOException(use);
}
// We need to convert the protocol to #dap4
if ("dap4".equalsIgnoreCase(xuri.getScheme())) {
xuri.setScheme("https"); // Note that this should be https, but
// test.opendap.org still uses http; one
// hopes that other servers are setup to
// redirect http: to https:
}
this.dsplocation = xuri.assemble(XURI.URLQUERY);
cancel = (cancelTask == null ? nullcancel : cancelTask);

Expand Down

0 comments on commit cdd73b0

Please sign in to comment.