Sergey,
yes that last line was wrong. Have corrected it now thanks.
What I'm doing is this:
ResponseBuilder builder = Response.ok();
builder.entity(f);
builder.type(media);
builder.header("Content-Length", f.length());
builder.header("Content-Type", contentType);
resp = builder.build();
So that last line calls into this:
public Response build() {
ResponseImpl r = new ResponseImpl(status, entity);
MetadataMap<String, Object> m = new MetadataMap<String, Object>();
m.putAll(metadata);
r.addMetadata(m);
reset();
return r;
}
My response object doens't have the entity or header objects i set
because the reset() call removes them from the Response object before
it is returned.
Am I calling it wrong?
Brad.
On Tue, Jun 17, 2008 at 10:45 AM, Sergey Beryozkin
<[EMAIL PROTECTED]> wrote:
> Hi Brad
>
> ResponseBuilder.build() should reset its state as per the API JavaDocs...
>
> I'm not sure why is it causing a problem for you. If you do
> Response.ok()
>
> then it returns a ResponseBuilder
>
> and then if you do
> return Response.ok().type(...).entity(file).build()
>
> then you should have a copy of the ResponseBuilder state copied to the
> instance of ResponseImpl...
>
> Actually, I see a problem :
>
>>>> ResponseBuilder builder =
>>>> Response.status(HttpURLConnection.HTTP_OK);
>>>> builder.entity(f);
>>>> builder.type(media);
>>>> builder.header("Content-Length", f.length());
>>>> resp = Response.ok().build();
>
> the last line is wrong, it should be
> resp = builder.build();
>
> Hope it helps, Sergey
>
>
>
>> Hi Sergey,
>>
>>
>>
>> One thing I have found is this:
>>
>> public Response build() {
>> ResponseImpl r = new ResponseImpl(status, entity);
>> MetadataMap<String, Object> m = new MetadataMap<String, Object>();
>> m.putAll(metadata);
>> r.addMetadata(m);
>> reset();
>> return r;
>> }
>>
>> How would you feel about removing that call to reset()? At the moment
>> I set all my response fields and then that overwrites them. Would it
>> break anything if I changed it?
>>
>> Cheers,
>> Brad.
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>