I have client apps that send a request to an endpoint without an Accept header. The endpoint fails with "Could not find acceptable representation" but I would like the controller to process the request anyway.
I'm writing a Java app that handles REST API requests and returns an OPDS feed. When the client sends a request and includes a header (on iOS the clients all include "accept=/") the endpoint works as expected.
But when the client (everything I've tested on Android) doesn't include this header, then Spring doesn't pass the request to the controller method and, instead, returns an HTTP 406 response instead of data.
I would like the controller method to be invoked regardless of the accept header's existence and always return content.
Not really much code to show, as this is more of an integration issue.
The iOS clients all submit requests with the following headers:
2019-04-27 14:07:16.362 DEBUG 74305 --- [nio-7171-exec-5] o.c.web.opds.OPDSRequestInterceptor : Header[accept]=*/*
2019-04-27 14:07:16.362 DEBUG 74305 --- [nio-7171-exec-5] o.c.web.opds.OPDSRequestInterceptor : Header[accept-language]=en-us
2019-04-27 14:07:16.362 DEBUG 74305 --- [nio-7171-exec-5] o.c.web.opds.OPDSRequestInterceptor : Header[connection]=keep-alive
2019-04-27 14:07:16.362 DEBUG 74305 --- [nio-7171-exec-5] o.c.web.opds.OPDSRequestInterceptor : Header[accept-encoding]=gzip, deflate
2019-04-27 14:07:16.362 DEBUG 74305 --- [nio-7171-exec-5] o.c.web.opds.OPDSRequestInterceptor : Header[user-agent]=Chunky/2.5.9002 CFNetwork/978.0.7 Darwin/18.5.0
But the Android clients all have sent:
2019-04-27 14:02:06.724 DEBUG 74305 --- [nio-7171-exec-1] o.c.web.opds.OPDSRequestInterceptor : Header[connection]=Keep-Alive
2019-04-27 14:02:06.724 DEBUG 74305 --- [nio-7171-exec-1] o.c.web.opds.OPDSRequestInterceptor : Header[user-agent]=Apache-HttpClient/UNAVAILABLE (java 1.5)
I would like to have the method receive the request regardless of the accept header.