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