-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#12170) Introduced http2-client.mod and http2-client-transport.mod. These modules download dependencies via a [files] section. They can be used to have the server provide the dependencies in case of a web application proxies request using HTTP/2. Fixed ContentProvider to set the context ClassLoader before reading the Jetty XML context file, which may reference classes from the web application. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
- Loading branch information
Showing
9 changed files
with
188 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
# DO NOT EDIT THIS FILE - See: https://jetty.org/docs/ | ||
|
||
[description] | ||
Adds the Jetty HTTP client to the server classpath. | ||
Adds the Jetty HTTP client dependencies to the server classpath. | ||
|
||
[tags] | ||
client | ||
|
||
[lib] | ||
lib/jetty-client-${jetty.version}.jar | ||
lib/jetty-alpn-client-${jetty.version}.jar | ||
lib/jetty-alpn-java-client-${jetty.version}.jar | ||
lib/jetty-client-${jetty.version}.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...tty-http2/jetty-http2-client-transport/src/main/config/modules/http2-client-transport.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[description] | ||
Adds the Jetty HTTP/2 client transport dependencies to the server classpath. | ||
|
||
[tags] | ||
client | ||
http2 | ||
|
||
[depends] | ||
client | ||
http2-client | ||
|
||
[files] | ||
maven://org.eclipse.jetty.http2/jetty-http2-client-transport/${jetty.version}/jar|lib/http2/jetty-http2-client-transport-${jetty.version}.jar | ||
|
||
[lib] | ||
lib/http2/jetty-http2-client-transport-${jetty.version}.jar |
18 changes: 18 additions & 0 deletions
18
jetty-core/jetty-http2/jetty-http2-client/src/main/config/modules/http2-client.mod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[description] | ||
Adds the Jetty HTTP/2 client dependencies to the server classpath. | ||
|
||
[tags] | ||
client | ||
http2 | ||
|
||
[files] | ||
maven://org.eclipse.jetty/jetty-alpn-client/${jetty.version}/jar|lib/jetty-alpn-client-${jetty.version}.jar | ||
maven://org.eclipse.jetty/jetty-alpn-java-client/${jetty.version}/jar|lib/jetty-alpn-java-client-${jetty.version}.jar | ||
maven://org.eclipse.jetty.http2/jetty-http2-client/${jetty.version}/jar|lib/http2/jetty-http2-client-${jetty.version}.jar | ||
|
||
[lib] | ||
lib/jetty-alpn-client-${jetty.version}.jar | ||
lib/jetty-alpn-java-client-${jetty.version}.jar | ||
lib/http2/jetty-http2-client-${jetty.version}.jar | ||
lib/http2/jetty-http2-common-${jetty.version}.jar | ||
lib/http2/jetty-http2-hpack-${jetty.version}.jar |
30 changes: 30 additions & 0 deletions
30
jetty-core/jetty-tests/jetty-test-http2-client-transport-provided-webapp/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-tests</artifactId> | ||
<version>12.0.13-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>jetty-test-http2-client-transport-provided-webapp</artifactId> | ||
<name>Core :: Tests :: HTTP/2 Client Transport Provided WebApp</name> | ||
|
||
<properties> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-server</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty.http2</groupId> | ||
<artifactId>jetty-http2-client-transport</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
59 changes: 59 additions & 0 deletions
59
...lipse/jetty/test/http2/client/transport/provided/HTTP2ClientTransportProvidedHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package org.eclipse.jetty.test.http2.client.transport.provided; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.eclipse.jetty.client.HttpClient; | ||
import org.eclipse.jetty.http2.client.HTTP2Client; | ||
import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2; | ||
import org.eclipse.jetty.server.Handler; | ||
import org.eclipse.jetty.server.Request; | ||
import org.eclipse.jetty.server.Response; | ||
import org.eclipse.jetty.util.Callback; | ||
|
||
public class HTTP2ClientTransportProvidedHandler extends Handler.Abstract | ||
{ | ||
private final HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(new HTTP2Client())); | ||
|
||
@Override | ||
protected void doStart() throws Exception | ||
{ | ||
addBean(httpClient); | ||
super.doStart(); | ||
} | ||
|
||
@Override | ||
public boolean handle(Request request, Response response, Callback callback) throws Exception | ||
{ | ||
// Verify that the HTTP2Client dependencies are provided by the server | ||
// by making a request to an external server, as if this Handler was a proxy. | ||
|
||
httpClient.newRequest("https://webtide.com/") | ||
.timeout(15, TimeUnit.SECONDS) | ||
.send(result -> | ||
{ | ||
if (result.isSucceeded()) | ||
{ | ||
response.setStatus(result.getResponse().getStatus()); | ||
callback.succeeded(); | ||
} | ||
else | ||
{ | ||
callback.failed(result.getFailure()); | ||
} | ||
}); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters