Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropwizard doesn't support HTTP trailers #8762

Closed
fmurray-r7 opened this issue May 15, 2024 · 2 comments
Closed

Dropwizard doesn't support HTTP trailers #8762

fmurray-r7 opened this issue May 15, 2024 · 2 comments

Comments

@fmurray-r7
Copy link

Dropwizard doesn't seem to support HTTP trailer response headers, despite trailers being supported by jetty.

Is this something that can be added, considering it is supported by the underlying library and is part of the HTTP specifications?

@zUniQueX
Copy link
Member

zUniQueX commented Jun 3, 2024

Hi @fmurray-r7. Since Jetty supports trailers, dropwizard supports them as well.

Trailers can be set through the servlet api. To do that, you'll inject the HttpServletResponse in your resource method and set the trailers:

@GET
public String helloWorld(@Context HttpServletResponse response) {
    response.setTrailerFields(() -> Map.of("Testkey", "Testvalue"));
    return "Hello World!";
}

To check, if the trailers are set correctly, you can use the Jetty client:

ContentResponse response = client
        .newRequest("http://localhost:8080")
        .method(HttpMethod.GET)
        .onResponseSuccess(response1 -> {
            if (response1 instanceof HttpResponse httpResponse) {
                System.out.println(httpResponse.getTrailers());
            }
        })
        .send();

@fmurray-r7
Copy link
Author

Ah, my mistake, thank you for the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants