TE: the getHeaderField() methods always return nulls for me :(
var gotContentEncoding = false;
var gotContentLength = false;
var gotContentType = false;
var gotDate = false;
var gotExpiration = false;
var gotLastModified = false;
for (var i = 0; ; i++)
{
var hdrName = conn.getHeaderFieldKey(i);
var hdrValue = conn.getHeaderField(i);
if (hdrName == null && hdrValue == null)
{
break;
}
if (hdrName != null)
{
this._headers[this._headers.length] = {h:hdrName, v:hdrValue};
switch (hdrName.toLowerCase())
{
case ''content-encoding'': gotContentEncoding = true; break;
case ''content-length'' : gotContentLength = true; break;
case ''content-type'' : gotContentType = true; break;
case ''date'' : gotDate = true; break;
case ''expires'' : gotExpiration = true; break;
case ''last-modified'' : gotLastModified = true; break;
}
}
}
// try to fill in any missing header information
var val;
val = conn.getContentEncoding();
if (val != null && !gotContentEncoding) this._headers[this._headers.length] = {h:''Content-encoding'', v:val};
val = conn.getContentLength();
if (val != -1 && !gotContentLength) this._headers[this._headers.length] = {h:''Content-length'', v:val};
val = conn.getContentType();
if (val != null && !gotContentType) this._headers[this._headers.length] = {h:''Content-type'', v:val};