diff --git a/README.md b/README.md index 4698dbab2b..eabb7472a7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Restlet Framework -## The leading RESTful Web API framework for Java +## The first REST API framework for Java Thanks to Restlet Framework's powerful routing and filtering capabilities, unified client and server Java API, developers can build secure and scalable RESTful web APIs. @@ -8,22 +8,21 @@ It is available in editions for all major platforms (Java SE/EE, Google App Engi It is available under the terms of either the Apache Software License 2.0 or the Eclipse Public License 1.0. -http://restlet.com +http://restlet.talend.com ## Learn more To learn more about Restlet Framework, please have a look at the following resources: -* [User Guide](http://restlet.com/technical-resources/restlet-framework/guide/2.3) -* [Tutorials](http://restlet.com/technical-resources/restlet-framework/tutorials/2.3) -* [JavaDocs](http://restlet.com/technical-resources/restlet-framework/javadocs/3.0) -* [Change Log](http://restlet.com/technical-resources/restlet-framework/misc/3.0/changes) -* [Download](http://restlet.com/downloads/current/) +* [User Guide](https://restlet.talend.com/documentation/user-guide/2.4/) +* [Tutorials](https://restlet.talend.com/documentation/tutorials/2.4/) +* [JavaDocs](https://restlet.talend.com/documentation/javadocs/2.4/) +* [Change Log](https://restlet.talend.com/documentation/2.4/changelog) +* [Download](https://restlet.talend.com/downloads/current/) * [Issue Tracker](https://github.com/restlet/restlet-framework-java/issues) * [Mailing List](https://groups.google.com/a/restlet.org/forum/#!forum/framework-discuss) * [Stack Overflow](http://stackoverflow.com/questions/tagged/restlet) -Copyright 2016 Restlet - -[![Build Status](https://travis-ci.org/restlet/restlet-framework-java.png?branch=master)](https://travis-ci.org/restlet/restlet-framework-java) +Copyright 2024 Qlik +[![Build Status](https://travis-ci.org/restlet/restlet-framework-java.svg?branch=master)](https://travis-ci.org/restlet/restlet-framework-java) diff --git a/modules/org.restlet/src/org/restlet/engine/connector/HttpServerHelper.java b/modules/org.restlet/src/org/restlet/engine/connector/HttpServerHelper.java index 4c489a5ac7..74c730a623 100644 --- a/modules/org.restlet/src/org/restlet/engine/connector/HttpServerHelper.java +++ b/modules/org.restlet/src/org/restlet/engine/connector/HttpServerHelper.java @@ -24,15 +24,15 @@ package org.restlet.engine.connector; -import java.io.IOException; -import java.net.InetSocketAddress; - -import org.restlet.Server; -import org.restlet.data.Protocol; - import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; +import org.restlet.Server; +import org.restlet.data.Protocol; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; /** * Internal HTTP server connector. @@ -56,8 +56,22 @@ public HttpServerHelper(Server server) { @Override public void start() throws Exception { - this.server = HttpServer.create(new InetSocketAddress(getHelped() - .getPort()), 0); + String addr = getHelped().getAddress(); + // Use ephemeral port + int port = getHelped().getPort() > 0 ? getHelped().getPort() : 0; + + if (addr != null) { + // This call may throw UnknownHostException and otherwise always + // returns an instance of INetAddress. + // Note: textual representation of inet addresses are supported + InetAddress iaddr = InetAddress.getByName(addr); + setAddress(new InetSocketAddress(iaddr, port)); + } else { + setAddress(new InetSocketAddress(port)); + } + + // Complete initialization + server = HttpServer.create(getAddress(), 0); server.createContext("/", new HttpHandler() { @Override public void handle(HttpExchange httpExchange) throws IOException { diff --git a/modules/org.restlet/src/org/restlet/engine/connector/HttpsServerHelper.java b/modules/org.restlet/src/org/restlet/engine/connector/HttpsServerHelper.java index 54f95e6cf6..e81577152e 100644 --- a/modules/org.restlet/src/org/restlet/engine/connector/HttpsServerHelper.java +++ b/modules/org.restlet/src/org/restlet/engine/connector/HttpsServerHelper.java @@ -24,24 +24,22 @@ package org.restlet.engine.connector; -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLParameters; - +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpsConfigurator; +import com.sun.net.httpserver.HttpsParameters; +import com.sun.net.httpserver.HttpsServer; import org.restlet.Server; import org.restlet.data.Protocol; import org.restlet.engine.ssl.DefaultSslContextFactory; import org.restlet.engine.ssl.SslContextFactory; import org.restlet.engine.ssl.SslUtils; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpsConfigurator; -import com.sun.net.httpserver.HttpsParameters; -import com.sun.net.httpserver.HttpsServer; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLParameters; +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; /** * Internal HTTPS server connector. Here is the list of additional parameters @@ -90,28 +88,24 @@ public void start() throws Exception { SslContextFactory sslContextFactory = SslUtils .getSslContextFactory(this); SSLContext sslContext = sslContextFactory.createSslContext(); + String addr = getHelped().getAddress(); + // Use ephemeral port + int port = getHelped().getPort() > 0 ? getHelped().getPort() : 0; if (addr != null) { // This call may throw UnknownHostException and otherwise always // returns an instance of INetAddress. // Note: textual representation of inet addresses are supported InetAddress iaddr = InetAddress.getByName(addr); - - // Note: the backlog of 50 is the default - setAddress(new InetSocketAddress(iaddr, getHelped().getPort())); + setAddress(new InetSocketAddress(iaddr, port)); } else { - int port = getHelped().getPort(); - - // Use ephemeral port - if (port > 0) { - setAddress(new InetSocketAddress(getHelped().getPort())); - } + setAddress(new InetSocketAddress(port)); } // Complete initialization - this.server = HttpsServer.create(new InetSocketAddress(getHelped() - .getPort()), 0); + server = HttpsServer.create(getAddress(), 0); + final SSLParameters sslParams = sslContext.getDefaultSSLParameters(); server.setHttpsConfigurator(new HttpsConfigurator(sslContext) { public void configure(HttpsParameters params) { diff --git a/modules/org.restlet/src/org/restlet/engine/io/PipeStream.java b/modules/org.restlet/src/org/restlet/engine/io/PipeStream.java index 97757f049e..903e67d9c5 100644 --- a/modules/org.restlet/src/org/restlet/engine/io/PipeStream.java +++ b/modules/org.restlet/src/org/restlet/engine/io/PipeStream.java @@ -69,12 +69,12 @@ public int read() throws IOException { final Integer value = queue.poll(QUEUE_TIMEOUT, TimeUnit.SECONDS); - this.endReached = (value == -1); if (value == null) { throw new IOException( "Timeout while reading from the queue-based input stream"); } else { + this.endReached = (value == -1); return value.intValue(); } } catch (InterruptedException ie) {