I have resources that are XML documents that I am sending using
DomRepresentation, and I have one area where I'm looking for a better solution.
I need my response to have a Content-length header. (Specifically, I have
clients talking through a Windows proxy which by default uses HTTP 1.0. I can't
require all my customers to change their Windows Internet settings to use only
HTTP 1.1, and it appears that 1.0 waits for some sort of timeout if there is no
Content-length, because it's very slow.)
I quickly discovered that if I call setSize on the Representation, my response
will have a Content-length. However, I'm looking for a good way to get the
length from the DomRepresentation. My current method is to write it to a
ByteArrayOutputStream and get the resulting length from that, but that seems
rather inefficient. Is there a more direct way to get it?
I understand that this is likely a limitation of the underlying DOM API, but I
thought I'd check whether anyone here knew of something I'd missed in either the
DOM API or DomRepresentation itself.
Thanks,
-- Jim