It does not happen with the latest version of wink.  
Unfortunately I can't use the latest version as i was trying to develop a 
custom Trust Association Intercepter that runs in the websphere base 
classloader.

Do you know where the Content-Length gets set?  Maybe I could override it.  I 
did a quick scan of the source and could not find it.

Thanks 

-J


Date: Sat, 31 Jan 2015 13:42:18 -0800
Subject: Re: [wink client] Wrong content-lenth when using outMultiPart
From: [email protected]
To: [email protected]

Can you reproduce the problem with the latest wink release ? If not, you can 
try deploying the wink jars with your application and setting the class loader 
to be parentLast in websphere when deploying the application.

On Sat, Jan 31, 2015 at 8:23 AM, Jay Mann <[email protected]> wrote:
I'm using the apache wink that is packaged with websphere 8.0.0.9.  I believe 
it is version 1.1.1.  I'm trying to send a multipart request from the wink 
client but it's setting the content-length to 239 when it should be 247.  It 
seems like it is treating the "\r\n" new lines as a single byte.  Here is the 
code.  I tried to specifically set the content-length in the resource header 
but it is overridden.  Since this is included in websphere i can really update 
the jar. Is there a workaround?



Any help is appreciated, thanks.



        RestClient client = new RestClient();

        Resource resource = 
client.resource("http://localhost:9999/Test/service/getUserInfo";);



        BufferedOutMultiPart requestEntity = new BufferedOutMultiPart();

        requestEntity.setBoundary(boundary);

        OutPart outPart = new OutPart();

        outPart.setBody(URLEncoder.encode("111", "UTF-8"));

        outPart.addHeader("Content-Disposition", "form-data; name=\"cdbId\"");

        requestEntity.addPart(outPart);

        outPart = new OutPart();

        outPart.setBody(URLEncoder.encode("222", "UTF-8"));

        outPart.addHeader("Content-Disposition", "form-data; name=\"passwd\"");

        requestEntity.addPart(outPart);



        ClientResponse string = resource.header("Content-Type", 
"multipart/form-data; boundary=" + boundary).header("Content-Length", 
"247").header("Connection", "keep-alive").post(requestEntity);



-- 
Luciano Resende
http://people.apache.org/~lresende
http://twitter.com/lresende1975
http://lresende.blogspot.com/
                                          

Reply via email to