@Test
    public void acceptNotSameAsContentType() throws Exception {
        final HelloService.Iface client =
                ThriftClients.builder(server.httpUri())
                             .path("/hello")
                             .serializationFormat(TEXT)
                             .setHeader(HttpHeaderNames.ACCEPT, "application/x-thrift; protocol=TBINARY")
                             .build(HelloService.Iface.class);
        assertThatThrownBy(() -> client.hello("Trustin")).isInstanceOf(TTransportException.class)
                                                         .cause()
                                                         .isInstanceOf(InvalidResponseHeadersException.class)
                                                         .hasMessageContaining(":status=406");
    }
Test of serialization format validation / detection based on HTTP headers.
thrift/thrift0.13/src/test/java/com/linecorp/armeria/server/thrift/ThriftSerializationFormatsTest.java