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

Ensure that Transfer-Encoding and Content-Length are not both set #29460

Merged
merged 1 commit into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,9 @@ public static void encodeResponseHeaders(ResteasyReactiveRequestContext requestC
vertxResponse.addResponseHeader(header, (CharSequence) HeaderUtil.headerToString(o));
}
}
if (header.equals("Transfer-Encoding")) { // using both headers together is not allowed
vertxResponse.removeResponseHeader("Content-Length");
}
} else {
List<CharSequence> strValues = new ArrayList<>(entry.getValue().size());
for (Object o : entry.getValue()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.jboss.resteasy.reactive.server.vertx.test.headers;

import static io.restassured.RestAssured.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

import org.jboss.resteasy.reactive.server.vertx.test.framework.ResteasyReactiveUnitTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class ChunkedHeaderTest {

@RegisterExtension
static ResteasyReactiveUnitTest TEST = new ResteasyReactiveUnitTest()
.withApplicationRoot((jar) -> jar.addClasses(TestResource.class));

@Test
public void testReturnUni() {
given()
.get("/test/hello")
.then()
.statusCode(200)
.headers("Transfer-Encoding", "chunked")
.headers("Content-Length", is(nullValue()));
}

@Path("/test")
public static class TestResource {

@GET
@Path("hello")
public Response hello() {
return Response.ok("hello").header("Transfer-Encoding", "chunked").build();
}
}
}