summaryrefslogtreecommitdiffstats
path: root/ds9
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2019-05-28 20:10:46 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2019-05-28 20:10:46 (GMT)
commit45619b5d0d1e761db43f1d8302c223b6746bb998 (patch)
tree9aeee967d67de409ef17e64cabcbac4bc93e36d8 /ds9
parent456533d93d7fccb14f26d57bea1cf1a993e51c1a (diff)
downloadblt-45619b5d0d1e761db43f1d8302c223b6746bb998.zip
blt-45619b5d0d1e761db43f1d8302c223b6746bb998.tar.gz
blt-45619b5d0d1e761db43f1d8302c223b6746bb998.tar.bz2
URL: more tolerant of mime types when downloading via http
Diffstat (limited to 'ds9')
-rw-r--r--ds9/doc/release/r8.1.html2
-rw-r--r--ds9/library/url.tcl22
2 files changed, 15 insertions, 9 deletions
diff --git a/ds9/doc/release/r8.1.html b/ds9/doc/release/r8.1.html
index b3fbad4..4dd67ac 100644
--- a/ds9/doc/release/r8.1.html
+++ b/ds9/doc/release/r8.1.html
@@ -79,6 +79,8 @@
<li><tt>05.10.2019 AST: update to version 8.7.1.</tt></li>
<li><tt>05.13.2019 OPENSSL: DS9 now links against its own version of openssl and no longer is dependent upon system libs.</tt></li>
<li><tt><b>05.15.2019 RELEASE version 8.1b1</b></tt></li>
+<li><tt>05.28.2019 URL: more tolerant of mime types when downloading via http.</tt></li>
+<li><tt><b>xx.xx.2019 RELEASE version 8.1b2</b></tt></li>
</ol>
</div>
</body>
diff --git a/ds9/library/url.tcl b/ds9/library/url.tcl
index 7ad5c60..ce63cd8 100644
--- a/ds9/library/url.tcl
+++ b/ds9/library/url.tcl
@@ -55,6 +55,7 @@ proc GetFileHTTP {url fn} {
-timeout $ihttp(timeout) \
-headers "[ProxyHTTP]"} token]} {
close $ch
+ Error "[msgcat::mc {Unable to locate URL}] $var(url)"
return
}
@@ -138,17 +139,20 @@ proc LoadURLFitsHTTP {url layer mode} {
set fn [tmpnam [file extension $r(path)]]
set ch [open $fn w]
- set token [http::geturl $url \
- -channel $ch \
- -binary 1 \
- -timeout $ihttp(timeout) \
- -headers "[ProxyHTTP]"]
+ if {[catch {set token [http::geturl $url \
+ -channel $ch \
+ -binary 1 \
+ -timeout $ihttp(timeout) \
+ -headers "[ProxyHTTP]"]}]} {
+ close $var(ch)
+ Error "[msgcat::mc {Unable to locate URL}] $url"
+ }
# reset errorInfo (may be set in http::geturl)
global errorInfo
set errorInfo {}
- catch {close $ch}
+ close $ch
upvar #0 $token t
@@ -225,8 +229,10 @@ proc LoadURLFitsHTTP {url layer mode} {
}
switch -- [string tolower $mime] {
+ "text/plain" -
+ "text/html" -
"application/octet-stream" {
- # its never fails, someone can't get there mime types correct.
+ # it never fails, someone can't get there mime types correct.
# Override the mime type based on path
switch -- [file extension $fn] {
.bz2 {set var(encoding) bzip2}
@@ -264,8 +270,6 @@ proc LoadURLFitsHTTP {url layer mode} {
"image/x-zfits" -
"binary/x-zfits" {set encoding pack}
- "text/plain" {}
- "text/html" -
default {
Error "[msgcat::mc {File not Found or Unable to load FITS data MIME type}] $mime"
return