Hello dropwizard devs,
I'm trying to spin up a dropwizard instance that supports HTTP/2 and I'm
not sure if my setup is right so I wanted to run it by you.
Since I'm trying this in a dev environment, I'm trying to use HTTP/2 plain
text as explained
here:
http://www.dropwizard.io/1.0.6/docs/manual/configuration.html#http-2-plain-text
And to make things easier I created a new project from scratch using
dropwizard 1.0.6.
Here are the important details of the pom.xml
<?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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<prerequisites>
<maven>3.0.0</maven>
</prerequisites>
<groupId>practice</groupId>
<artifactId>dwtest</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dw</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<dropwizard.version>1.0.6</dropwizard.version>
<mainClass>practice.dwApplication</mainClass>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-bom</artifactId>
<version>${dropwizard.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
</dependency>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-http2</artifactId>
</dependency>
</dependencies>
<!-- Note that more content goes here, but I decided to hide it for
simplicity -->
</project>
Here's the yml file I use to start the application
logging:
level: INFO
loggers:
practice: DEBUG
server:
applicationConnectors:
- type: h2c
port: 8446
maxConcurrentStreams: 1024
initialStreamRecvWindow: 65535
The application class only registers a hello world resource
public static void main(final String[] args) throws Exception {
new dwApplication().run(args);
}
@Override
public String getName() {
return "dw";
}
@Override
public void initialize(final Bootstrap<dwConfiguration> bootstrap) {
// TODO: application initialization
}
@Override
public void run(final dwConfiguration configuration,
final Environment environment) {
final HelloWorldResource resource = new HelloWorldResource();
environment.jersey().register(resource);
}
And here's the resource.
@Path("/hello-world")
@Produces(MediaType.APPLICATION_JSON)
public class HelloWorldResource {
private final AtomicLong counter;
public HelloWorldResource() {
this.counter = new AtomicLong();
}
@GET
public String sayHello(@QueryParam("name") Optional<String> name) {
return "dummy-test";
}
}
I build the project with maven and I start the server by running: java -jar
target/dwtest-1.0-SNAPSHOT.jar server config.yml
Now when I issue the following curl command:
curl -I --http2 http://localhost:8446/hello-world
I get this in response:
HTTP/1.1 101 Switching Protocols
HTTP/2 200
date: Tue, 07 Feb 2017 04:13:37 GMT
content-length: 10
content-type: application/json
And the logs of my dw instance display:
0:0:0:0:0:0:0:1 - - [07/Feb/2017:04:13:38 +0000] "HEAD /hello-world
HTTP/1.1" 200 0 "-" "curl/7.52.1" 77
So the questions are:
1- Is the request handled as HTTP/2? I'm inclined to say no, based on the
logs, but figured it is better to ask
2- Is there any missing configuration in my setup?
3- Is the request I'm issuing to the server wrong?
Thanks in advance
--
You received this message because you are subscribed to the Google Groups
"dropwizard-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.