You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-dev@incubator.apache.org by Nascif Abousalh-Neto <Na...@sas.com> on 2007/10/26 00:13:46 UTC

Error with URL resolver when downloading with wrong MIME type

We jst had a very interesting problem when using the url resolver. I am
documenting it here in the hope that it might help other developer in
the same situation, and that maybe there is a way to protect against it
in Ivy; I don't think it is really an Ivy bug.

We found a situation where depending on the *name* of the jar the web
server would return not its content but an error message - that Ivy
would then save as a .jar file, which was obviously incorrect. In our
case, a jar file name ending  in "map.jar" triggers a different MIME
type response from the web server; instead of returning the file
contents (what you get when asking for text/plain), the web server is
returning an HTTP error message (because it thinks we are asking for a
text/html).

I checked using wget from my desktop pointing back to the ivy repository
web server. All the files in the examples below are exactly the same - I
just made copies with different names. See how the suffix affects the
MIME type selection.

The following trace shows what happens when you ask for such a file
using wget. Note the mime type:

/home/dev/LoadVJR/rr > wget
http://ivy.unx.sas.com/Repositories/naabou/test50/ivy-DEVR/SAS/sas.sxle.
map/9.2.0.20071018131512/sas.sxle.map.jar
--11:21:33--
http://ivy.unx.sas.com:80/Repositories/naabou/test50/ivy-DEVR/SAS/sas.sx
le.map/9.2.0.20071018131512/sas.sxle.map.jar
           => `sas.sxle.map.jar.1'
Connecting to ivy.unx.sas.com:80... connected!
HTTP request sent, awaiting response... 200 OK
Length: 372 [text/html]

    0K ->                                                        [100%]

11:21:33 (363.28 KB/s) - `sas.sxle.map.jar.1' saved [372/372]

Here you can see the content - not what you would expect in a .jar...

/home/dev/LoadVJR/rr > cat sas.sxle.map.jar.1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html><head>
<title>Menu for
/Repositories/naabou/test50/ivy-DEVR/SAS/sas.sxle.map/9.2.0.200710181315
12/sas.sxle.map.jar</title>
</head><body>
<h1>Menu for
/Repositories/naabou/test50/ivy-DEVR/SAS/sas.sxle.map/9.2.0.200710181315
12/sas.sxle.map.jar</h1>
<hr />



[an internal server error occured]


</body>
</html>

Same file, different name, correct mime type and behavior:

/home/dev/LoadVJR/rr > wget
http://ivy.unx.sas.com/Repositories/naabou/test50/ivy-DEVR/SAS/sas.sxle.
map/9.2.0.20071018131512/sas.sxle.mop.jar
--11:23:09--
http://ivy.unx.sas.com:80/Repositories/naabou/test50/ivy-DEVR/SAS/sas.sx
le.map/9.2.0.20071018131512/sas.sxle.mop.jar
           => `sas.sxle.mop.jar'
Connecting to ivy.unx.sas.com:80... connected!
HTTP request sent, awaiting response... 200 OK
Length: 125,768 [text/plain]

    0K -> .......... .......... .......... .......... .......... [ 40%]
   50K -> .......... .......... .......... .......... .......... [ 81%]
  100K -> .......... .......... ..                               [100%]

11:23:09 (119.94 MB/s) - `sas.sxle.mop.jar' saved [125768/125768]

Another file with the same problematic suffix:

/home/dev/LoadVJR/rr > wget
http://ivy.unx.sas.com/Repositories/naabou/test50/ivy-DEVR/SAS/sas.sxle.
map/9.2.0.20071018131512/test.map.jar
--11:25:00--
http://ivy.unx.sas.com:80/Repositories/naabou/test50/ivy-DEVR/SAS/sas.sx
le.map/9.2.0.20071018131512/test.map.jar
           => `test.map.jar'
Connecting to ivy.unx.sas.com:80... connected!
HTTP request sent, awaiting response... 200 OK
Length: 364 [text/html]

    0K ->                                                        [100%]

11:25:00 (355.47 KB/s) - `test.map.jar' saved [364/364]

Perhaps Ivy could check the returned MIME type and report an error if it
is not text/plain, or if the size is two small? 
Or even better, find a way to tell the server what is the desired MIME
type.

Thanks,
  Nascif