This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push: new 2cd0a90 [SCB-2277]upgrade httpcomponents from 4.5.7 to 4.5.13 (#2409) 2cd0a90 is described below commit 2cd0a9053e326e6b9c3b7d52e06564de93c7734a Author: liubao68 <bi...@qq.com> AuthorDate: Tue Jun 15 10:26:25 2021 +0800 [SCB-2277]upgrade httpcomponents from 4.5.7 to 4.5.13 (#2409) --- .../core/invocation/endpoint/EndpointUtils.java | 44 +++++++++++++++------- dependencies/default/pom.xml | 2 +- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/org/apache/servicecomb/core/invocation/endpoint/EndpointUtils.java b/core/src/main/java/org/apache/servicecomb/core/invocation/endpoint/EndpointUtils.java index 999c067..6aa4cc5 100644 --- a/core/src/main/java/org/apache/servicecomb/core/invocation/endpoint/EndpointUtils.java +++ b/core/src/main/java/org/apache/servicecomb/core/invocation/endpoint/EndpointUtils.java @@ -30,18 +30,6 @@ import org.apache.servicecomb.core.exception.Exceptions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * <pre> - * http://xxx -> rest://xxx - * https://xxx -> rest://xxx?sslEnabled=true - * - * h2c://xxx -> rest://xxx?protocol=http2 - * h2://xxx -> rest://xxx?sslEnabled=true&protocol=http2 - * - * xxx -> rest://xxx?protocol=http2 - * other://xxx -> other://xxx - * </pre> - **/ public final class EndpointUtils { private static final Logger LOGGER = LoggerFactory.getLogger(EndpointUtils.class); @@ -99,6 +87,22 @@ public final class EndpointUtils { return new Endpoint(transport, uriEndpoint); } + /** + * <pre> + * http://xxx -> rest://xxx + * https://xxx -> rest://xxx?sslEnabled=true + * + * h2c://xxx -> rest://xxx?protocol=http2 + * h2://xxx -> rest://xxx?sslEnabled=true&protocol=http2 + * + * xxx -> rest://xxx:port?protocol=http2 + * xxx?a=a1 -> rest://xxx:port?a=a1&protocol=http2 + * other://xxx -> other://xxx + * </pre> + * + * This method provided for convenience of handling user input endpoints, and do not have a strict meaning. Make sure all unit test cases + * work before change. + **/ public static String formatFromUri(String inputUri) { try { return doFormatFromUri(inputUri); @@ -111,7 +115,7 @@ public final class EndpointUtils { URIBuilder builder = new URIBuilder(inputUri); if (builder.getScheme() == null) { builder.setScheme(H2C); - builder.setHost(builder.getPath()); + builder.setHost(extractHostFromPath(builder)); builder.setPath(null); } @@ -123,6 +127,20 @@ public final class EndpointUtils { return format(builder, schemeMeta); } + private static String extractHostFromPath(URIBuilder builder) { + String path = builder.getPath(); + if (path == null) { + return null; + } + if (path.startsWith("/")) { + path = path.substring(1); + } + if (path.indexOf("/") != -1) { + path = path.substring(0, path.indexOf("/")); + } + return path; + } + private static String format(URIBuilder builder, SchemeMeta schemeMeta) throws URISyntaxException { if (schemeMeta.ssl) { builder.addParameter("sslEnabled", "true"); diff --git a/dependencies/default/pom.xml b/dependencies/default/pom.xml index fb9800a..120d7d5 100644 --- a/dependencies/default/pom.xml +++ b/dependencies/default/pom.xml @@ -58,7 +58,7 @@ <hdr-histogram.version>2.1.10</hdr-histogram.version> <hibernate.version>6.0.2.Final</hibernate.version> <hibernate-validator.version>6.1.5.Final</hibernate-validator.version> - <httpcomponents.version>4.5.7</httpcomponents.version> + <httpcomponents.version>4.5.13</httpcomponents.version> <hystrix.version>1.5.18</hystrix.version> <jackson.version>2.12.1</jackson.version> <javakaffee.version>0.26</javakaffee.version>