gzipped images in SIAP 1.0

Thomas McGlynn tam at milkyway.gsfc.nasa.gov
Tue May 22 10:07:17 PDT 2007


In a perfect world that sounds about right.  If you want
to be a bit more defensive, then in addition to looking
at the content encoding, you also look at the first two
bytes of data you download.  If you're expecting
a non-compressed FITS file and you get "SI" all is copacetic
and you go ahead.  If you get the hex code for a gzip
file (x1F, x8b I think) then you assume the user sent
you a gzip file and forgot to mention it...  You can also
check for .Z compression if you like.  If you don't recognize
the first two bytes it's very likely some kind of text, HTML or
XML error string.

Ideally you do this check even if you got
got a content-encoding, since the user may have expected to
write a compressed FITS file and then ran into an error and
sent some error message instead -- and it's unlikely they
sent it as a compressed FITS file.

	Tom

Roy Williams wrote:
> Thank you all for your help with this especially Tom and Norman. I am 
> seeing how to do it without tedious changes to SIAP protocol. Is the 
> below how it should work?
> Roy
> 
> (1) My client code searches for a format attribute which contains the 
> string "image/fits"
> 
> (2) It then gets http headers plus data blob from the given URL.
> 
> (3) If the headers have a content-encoding of gzip, then uncompress like 
> this
>    if headers.has_key('content-encoding') and 
> headers['content-encoding'] == 'gzip':
>        gunzip the blob
> 
> 



More information about the dal mailing list