Skip to content

janweinschenker/jdk9-jigsaw-http2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Showcasing the HTTP/2 Client from JDK9

Code-examples showcasing the http2-implementation of JDK 9.

Information concerning the incubator status of the http client: As of the jigsaw jdk9, build 149. the http client has been moved to incubator status. It will not be part of the final API of jdk9.

There is currently an Issue in IntelliJ 2016.3 that prevents projects based on the Jigsaw-JDK to run properly. Use IntelliJ 2017.1 instead.

Contents

1 How to run this Code
1.1 Prerequisites
1.2 Setup instructions

2 Running the examples
2.1 Fetching a list of target URIs asynchronously
2.2 Fetching a list of target URIs asynchronously with multi response
2.3 Cancel an HTTP request
2.4 Run multiple requests and display milliseconds
2.5 Clean the target and downloads folder

3 Contribute

1 How to run this Code

1.1 Prerequisites

  1. Apache Maven (the maven executable itself may run with a JVM < version 9)
  2. A working maven-toolchains-plugin configuration file (~/.m2/toolchains.xml)
  3. JDK 9 with Project Jigsaw
  4. Optional: An IDE with JDK9 support.
    1. Eclipse Neon with its Java 9 Support Plugin.
    2. IntelliJ IDEA 2017.1 or newer

1.2 Setup and compile and compile instructions

  1. Clone this project to your local drive.
  2. Download and install JDK 9 with Project Jigsaw
  3. Add the home directory of the Jigsaw-JDK to your toolchains.xml. See the example file at toolchain/toolchains.xml
  4. In the project folder call $> mvn clean:clean package
    • Maven should use the JDK 9 javac compiler to compile the sources.
  5. The setup is complete, when $> mvn clean:clean package has build successfully.

2 Running the examples

The examples can be executed with the exec-maven-plugin.

2.1 Fetching a list of target URIs asynchronously

This example is implemented in ResponseAsyncExample.java

  1. If not done already, compile the sources
    • $> mvn clean:clean package
  2. Execute the example code with maven by using the correct profile.
    • $> mvn exec:exec -PResponseAsyncExample
  3. There is also a bash script that starts this maven target
    • ./script/run_single.sh

2.2 Fetching a list of target URIs asynchronously with multi response

This example is implemented in ResponseAsyncMultiExample.java.

The client will download an HTML file from the server. If the server pushes any other resources, they will be processed as well.

  1. If not done already, compile the sources
  2. $> mvn clean:clean package
  3. Execute the example code with maven by using the correct profile.
  4. $> mvn exec:exec -PResponseAsyncMultiExample
  5. There is also a bash script that starts this maven target
  6. ./script/run_multi.sh

2.3 Cancel an HTTP request

This example is implemented in CancelClientExample.java.

The client will initiate an HTTP GET request and will cancel it after 10 milliseconds.

  1. If not done already, compile the sources
  2. $> mvn clean:clean package
  3. Execute the example code with maven by using the correct profile.
  4. $> mvn exec:exec -PCancelClientExample
  5. There is also a bash script that starts this maven target
  6. ./script/run_cancel.sh

2.4 Run multiple requests with HTTP/1.1 or HTTP/2.0

This example is implemented in ResponseAsyncCompare.java.

The client will run a number of requests against a server. At the end, it will display, how many milliseconds were needed to complete this task.

  1. If not done already, compile the sources
  2. $> mvn clean:clean package
  3. Execute the example code with maven by using the correct profile.
  4. $> mvn exec:exec -PResponseAsyncCompare
  5. There is also a bash script that starts this maven target
  6. run 2000 HTTP1.1 requests: ./script/run_compare.sh HTTP1_1 2000
  7. run 2000 HTTP2 requests: ./script/run_compare.sh HTTP2 2000

2.5 Clean the target and downloads folder

Call $> mvn clean:clean.

3 Contribute

Please feel free to propose bugfixes and changes to this showcase in a pull request.

About

Code-examples showcasing the http2-implementation of JDK 9.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published