-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Http header Content-Type updated can be ignored in incoming request matching #45058
Comments
/cc @geoand (kotlin) |
What version of Quarkus are you seeing this issue for? Better yet, if you could attach a small sample that we can use to see the problem in action, it would be great |
I use the The filter code is already present in the bug description. And my controller looks like @ApplicationScoped
@Path("/api/versions")
class VersioningResource {
@GET
@Path("/{id}")
fun get1(
@PathParam("id") id: String
): Version1 {
return Version1(id)
}
@GET
@Path("/{id}")
@Produces("application/vnd.acme.v1+json")
fun get2(
@PathParam("id") id: String
): Version2 {
return Version2(id)
}
@POST
@Path("/search")
fun search1(
search: Version1,
@QueryParam("pageSize") pageSize: Int
): List<Version1> {
return listOf(
Version1("1"),
Version1("2"),
Version1("3")
)
}
@POST
@Path("/search")
@Consumes("application/vnd.acme.v1+json")
@Produces("application/vnd.acme.v1+json")
fun search2(
search: Version2,
@QueryParam("pageSize") pageSize: Int
): List<Version2> {
return listOf(
Version2("1"),
Version2("2"),
Version2("3")
)
}
@POST
fun create1(
body: Version1
): Response {
return Response.created(URI.create("/api/version/${body.id}")).build()
}
@POST
@Consumes("application/vnd.acme.v1+json")
fun create2(
body: Version2
): Response {
return Response.created(URI.create("/api/version/${body.name}")).build()
}
}
data class Version1(
val id: String
)
data class Version2(
val name: String
)
|
If you could attach the sample project that has that code you are showing, it would be marvelous |
It is available here : https://github.com/alexandre-baron/bug-media-type-mapper |
🙏🏽 |
Describe the bug
Hi. In a context where a
ContainerRequestFilter
update some properties of the HTTP request:version
is present, update theAccept
and theContent-Type
HTTP headersWith a controller reacting on
/api/versions
with several methods:GET /api/versions/{id}
producesapplication/json
GET /api/versions/{id}
producesapplication/vnd.acme.v1+json
POST /api/versions
consumesapplication/json
POST /api/versions
consumesapplication/vnd.acme.v1+json
And payload schema for:
application/json
is an object with a fieldid
application/application/vnd.acme.v1+json
is an object with a fieldname
When the
GET /api/versions/{id}
is called with:The usage of
version
parameter work and change the response content-type.When the
POST /api/versions
is called with:The usage of
version
parameter throw an HTTP error, that indicate the web server try to map the request payload to the schema ofapplication/json
.Behavior is not consistent between update of
Content-Type
header andAccept
header.After investigation, I fall in the
org.jboss.resteasy.reactive.server.handlers.MediaTypeMapper
that is called when two methods have the same path.Its class javadoc indicates
Omitting the non-reassuring nature of the last line, I find this line (cf.
quarkus/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/MediaTypeMapper.java
Line 61 in a390e8a
It is called to get the content type of the request payload.
But, without javadoc on the
serverRequest()
andgetRequestHeader()
methods to indicate theirs goal, I deduce that it retrieve orginal HTTP headers and not updated ones.Replace this code by
requestContext.getRequestHeaders().getHeaderString(HttpHeaders.CONTENT_TYPE)
seems to search in the updated request headers instead of the originals ones.But I can't be sure of this fix, as the javadoc on these interfaces is missing.
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
No response
Quarkus version or git rev
No response
Build tool (ie. output of
mvnw --version
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: