rocketraman
11/06/2024, 11:45 PMContentNegotiation
/ json
installed. I want one particular request to return application/pdf
. I've specified accept(ContentType.Application.Pdf).withParameter("q", "2.0")
to try and get the server to return PDF instead, but it doesn't work -- seems the Spring server doesn't like a quality value > 1.
It seems like the automatic ContentNegotation
Accept
header should add application/json
with a lower quality value so that the user can override it on a per-request basis.
Is there a workaround to this?Olivier Patry
11/07/2024, 8:14 AMcontentType(ContentType.Application.Pdf)
in the request?
I use this for instance
val response = <http://httpClient.post|httpClient.post>("...") {
contentType(ContentType.Application.Json)
setBody(obj)
}
rocketraman
11/07/2024, 1:17 PMContentType
tells the server what the client is sending. I'm talking about the Accept
header which tells the server what we want to receive in the response.rocketraman
11/07/2024, 1:47 PMChrimaeon
11/07/2024, 7:19 PMapplication/pdf
. so when making the request, Ktor can handle the response and will set the header correctly if you specify it.rocketraman
11/07/2024, 7:25 PMContentNegotiation
plugin will simply result in both types added into the Accept
header, which is exactly what already happens by specifying accept(ContentType.Application.Pdf)
in the RequestBuilder
.Chrimaeon
11/07/2024, 7:29 PMrocketraman
11/07/2024, 7:29 PM