cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabien Thouny (JIRA)" <>
Subject [jira] [Created] (CXF-5349) Provide ability to disable chunked transfer encoding for entity
Date Mon, 21 Oct 2013 17:38:42 GMT
Fabien Thouny created CXF-5349:

             Summary: Provide ability to disable chunked transfer encoding for
                 Key: CXF-5349
             Project: CXF
          Issue Type: Improvement
          Components: JAX-RS
    Affects Versions: 2.7.7
            Reporter: Fabien Thouny

As it was done for byte array in CXF-4760, it will be nice to be able to disable chunked transfer
encoding for entity in BinaryDataProvider.

I tried to provide a custom BinaryDataProvider as a workaround :
public class CustomBinaryDataProvider extends BinaryDataProvider<Object> {

    public long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
        if (File.class.isAssignableFrom(t.getClass())) {
            return ((File) t).length();
        return super.getSize(t, type, genericType, annotations, mt);

but it seems not to be enough because there's an explicit check in JAXRSUtils#writeMessageBody
to put the "Content-Length" header only for byte arrays :
MessageBodyWriter<Object> writer = ((WriterInterceptorMBW)writers.get(0)).getMBW();
            if (type == byte[].class) {
                long size = writer.getSize(entity, type, genericType, annotations, mediaType);
                if (size != -1) {
                    httpHeaders.putSingle(HttpHeaders.CONTENT_LENGTH, Long.toString(size));
            writer.writeTo(entity, type, genericType, annotations, mediaType,
                           httpHeaders, entityStream);

Thanks for your help,


This message was sent by Atlassian JIRA

View raw message