Skip to content

Commit

Permalink
Merge pull request #29460 from geoand/#29059
Browse files Browse the repository at this point in the history
Ensure that Transfer-Encoding and Content-Length are not both set
  • Loading branch information
geoand authored Nov 24, 2022
2 parents 252697a + b632c9e commit 5911db1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
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();
}
}
}

0 comments on commit 5911db1

Please sign in to comment.