Skip to content

Commit a2d148d

Browse files
authored
Upgrade HttpClient to 5.2 and switch to path-first URLs (#42)
1 parent 4dc2b2d commit a2d148d

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

labkey-client-api/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# The LabKey Remote API Library for Java - Change Log
22

3+
## version 4.1.0-SNAPSHOT
4+
*Released*: TBD
5+
* Migrate internal HTTP handling to use Apache HttpClient 5.2
6+
* Generate and execute path-first URLs
7+
38
## version 4.0.0
49
*Released*: 26 October 2022
510
* Migrate to a new JSON library: [JSON-java](https://github.com/stleary/JSON-java). The previous library,

labkey-client-api/gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ artifactory_contextUrl=https://labkey.jfrog.io/artifactory
77
sourceCompatibility=17
88
targetCompatibility=17
99

10-
gradlePluginsVersion=1.35.0
10+
gradlePluginsVersion=1.36.1
1111

1212
commonsCodecVersion=1.15
1313
commonsLoggingVersion=1.2
1414

1515
hamcrestVersion=1.3
1616

17-
httpclient5Version=5.1.3
18-
httpcore5Version=5.1.4
17+
httpclient5Version=5.2
18+
httpcore5Version=5.2
1919

2020
jsonObjectVersion=20220924
2121

labkey-client-api/src/org/labkey/remoteapi/Command.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,6 @@ private URI createURI(Connection connection, String folderPath) throws URISyntax
476476

477477
StringBuilder path = new StringBuilder(uri.getPath() == null || "".equals(uri.getPath()) ? "/" : uri.getPath());
478478

479-
//add the controller name
480-
String controller = getControllerName();
481-
if (controller.charAt(0) != '/' && path.charAt(path.length() - 1) != '/')
482-
path.append('/');
483-
path.append(controller);
484-
485479
//add the folderPath (if any)
486480
if (null != folderPath && folderPath.length() > 0)
487481
{
@@ -491,11 +485,25 @@ private URI createURI(Connection connection, String folderPath) throws URISyntax
491485
path.append(folderPathNormalized);
492486
}
493487

488+
if (path.charAt(path.length() - 1) != '/')
489+
path.append('/');
490+
491+
//add the controller name
492+
String controller = getControllerName();
493+
//for now, strip leading /. TODO: For next major release, throw
494+
if (controller.charAt(0) == '/')
495+
controller = controller.substring(1);
496+
//for now, strip trailing /. TODO: For next major release, throw
497+
if (controller.charAt(controller.length() - 1) == '/')
498+
controller = controller.substring(0, controller.length() - 1);
499+
path.append(controller);
500+
494501
//add the action name + ".api"
495502
String actionName = getActionName();
496-
if (actionName.charAt(0) != '/' && path.charAt(path.length() - 1) != '/')
497-
path.append('/');
498-
path.append(actionName);
503+
//for now, strip leading /. TODO: For next major release, throw
504+
if (actionName.charAt(0) == '/')
505+
actionName = actionName.substring(1);
506+
path.append("-").append(actionName);
499507
if (!actionName.endsWith(".api"))
500508
path.append(".api");
501509

@@ -573,5 +581,4 @@ public void setRequiredVersion(double requiredVersion)
573581
{
574582
_requiredVersion = requiredVersion;
575583
}
576-
577584
}

0 commit comments

Comments
 (0)