Mime-Type applet - test

A

Andrew Thompson

There is a new mime-type check applet available.

The applet can be configured by URL query parameters,
and provides a text field to specify an User-Agent string
for those servers that (sensibly) refuse connections to
clients that identify themselves as 'null'.

Code: (LGPL - though not explicitly stated in the source)
<http://pscode.org/javadoc/src-html/org/pscode/mime/MimeType.html>
Homepage: <http://pscode.org/mime/>
Help: <http://pscode.org/mime/help.html>
Config. : <http://pscode.org/mime/form.html>

Questions:
1) Does the applet work for you? *
2) Any suggestions on improving the code?
3) At the moment, only URLs that return a response
code of 200 (HTTP status OK) are checked, should I
allow an 'override' of that in case there are other
response codes that make it worth doing the check
anyway?
4) In the 'help' files, I use HTML forms to represent
the applet. Here (in my FF) they look very similar to
the applet itself, is that the same for you?
5) Any suggestions on improving the help page?

* Tests.

Here are a couple of tests pre-configured by URL,
but feel free to visit the form and make up your own.

Sandboxed
Tracker sound player JNLP off my site.
<http://pscode.org/mime/applet.html?media.url=http://pscode.org
%2Flib%2Ftracker-all.jnlp&mime.type=application%2Fx-java-jnlp-
file&ua.string=>
Expect message 1:
"Served type
'application/x-java-jnlp-file'
matches one of the expected types."

Non-existent resource.
<http://pscode.org/mime/applet.html?media.url=http://pscode.org
%2Fno.jnlp&mime.type=application%2Fx-java-jnlp-file&ua.string=>
Expect message 2:
"Response Code: 404.
Cannot proceed!"

Trusted.
Knute Johnson's Image Fader example JNLP
<http://pscode.org/mime/applet.html?media.url=http:/
%2Frabbitbrush.frazmtn.com%2Ffader.jnlp&mime.type=application%2Fx-java-
jnlp-file&ua.string=>
Message 1

John B. Matthews' AlphaComposite example JNLP
<http://pscode.org/mime/applet.html?media.url=http:/
%2Fsites.google.com%2Fsite%2Fdrjohnbmatthews%2Fcomposite
%2FAlphaComposite.jnlp%3Fattredirects%3D0&mime.type=application%2Fx-
java-jnlp-file&ua.string=>
Message 1 (I am surprised that site allowed
'null' UA clients! Was expecting a '503'.)
 
A

Andrew Thompson

There is a new mime-type check applet available.

All it took was going public to discover the
first bug! (1)

In the source I attempt to catch an
AccessControlException if the applet is
sandboxed and attempting to reach across
domains.
<http://pscode.org/javadoc/src-html/org/pscode/mime/MimeType.html#line.
125>

OTOH the result of the attempt is a
RuntimeException that wraps the ACE,
as shown in the help.
<http://pscode.org/mime/help.html#sandbox>

I am looking into it..

(1) It seems that is always the case. Must be
a Murphy's law corollary in there somewhere.
 
J

John B. Matthews

Andrew Thompson said:
There is a new mime-type check applet available.

The applet can be configured by URL query parameters,
and provides a text field to specify an User-Agent string
for those servers that (sensibly) refuse connections to
clients that identify themselves as 'null'.

Code: (LGPL - though not explicitly stated in the source)
<http://pscode.org/javadoc/src-html/org/pscode/mime/MimeType.html>
Homepage: <http://pscode.org/mime/>
Help: <http://pscode.org/mime/help.html>
Config. : <http://pscode.org/mime/form.html>

Questions:
1) Does the applet work for you? *
Yes.

2) Any suggestions on improving the code?

Would 4-space tabs be easier to read?
3) At the moment, only URLs that return a response
code of 200 (HTTP status OK) are checked, should I
allow an 'override' of that in case there are other
response codes that make it worth doing the check
anyway?
4) In the 'help' files, I use HTML forms to represent
the applet. Here (in my FF) they look very similar to
the applet itself, is that the same for you?

They look good, so good that I spent a minute
wondering why the components were disabled. :)
5) Any suggestions on improving the help page?

Maybe, "Examples of Mime-Type checker applet in use."
[...]
John B. Matthews' AlphaComposite example JNLP
<http://pscode.org/mime/applet.html?media.url=http:/
%2Fsites.google.com%2Fsite%2Fdrjohnbmatthews%2Fcomposite
%2FAlphaComposite.jnlp%3Fattredirects%3D0&mime.type=application%2Fx-
java-jnlp-file&ua.string=>
Message 1 (I am surprised that site allowed
'null' UA clients! Was expecting a '503'.)

I'm surprised jnlp works at all; applets are forbidden.

Why 503 Service Unavailable? Not that I see a better one:

<http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html>
 
A

Andrew Thompson

(embarrassed) I thought that meant 'Not Authorised'
or 'Refused'.  ;)

Maybe I should just send the user off to the W3
document you linked, rather than go into deep,
meaningful and wrong descriptions in my help page.
 
R

Roedy Green

There is a new mime-type check applet available.

Mine is posted at http://mindprod.com/applet/mimecheck.html

The main difference from Andrew's is it maps extensions to a list of
plausible Mime types, so you know if you are getting something
reasonable, not just a legal mime.

At Andrew's urging, I modified mine to detect 404 and other errors and
show them as such rather than as incorrect mime types.

source is provided.
--
Roedy Green Canadian Mind Products
http://mindprod.com

Without deviation from the norm, progress is not possible.
~ Frank Zappa (born: 1940-12-21 died: 1993-12-04 at age: 52)
 
A

Andrew Thompson

Mine is posted athttp://mindprod.com/applet/mimecheck.html

The main difference from Andrew's is it maps extensions to a list of
plausible Mime types, so you know if you are getting something
reasonable, not just a legal mime.

I like that aspect of your applet, but will not
be attempting to replicate it in mine. I am
guessing you have a file that identifies mime-types
by extension?

My applet does ask Java to guess a mime-type if
not supplied, but I noticed that:
a) It does not guess JNLP!
b) It is fooled by a name ending with query
arguments.
e.g.
index.html -> text/html
index.html?msg=Hi -> ?
At Andrew's urging, I modified mine to detect 404 and other errors and
show them as such rather than as incorrect mime types.

It's always nice to make suggestions to site
owners/software suppliers that you know *care*
about their product and will act expediently.

If I had not been so confident you would alter
your applet 'in a jiffy', I would probably have
started this thread before informing you of the
minor inconsistency I noticed.
 
J

John B. Matthews

Andrew Thompson said:
Maybe I should just send the user off to the W3
document you linked, rather than go into deep,
meaningful and wrong descriptions in my help page.

Surely both. I would add a dismal jeremiad on the state of the internet,
a protracted screed on the failings of the IETF, and an exhortation to
take <http://www.ietf.org/rfc/rfc2119.txt> more seriously; sadly, I am
too indolent.

I genuinely liked the color coding.
 
A

Andrew Thompson

Surely both.

Good idea.
..I would add a dismal jeremiad ..

Well there you go. I claim I learn something
new every day I read/contribute to the groups,
but it is a long time since I've heard a new(1)
(non-technical) word or term used.

(1) New to me, at least. ;)
 
A

Andrew Thompson

...
Crack open a jeroboam of Perrier-Jouët to celebrate.
<http://upload.wikimedia.org/wikipedia/commons/1/1f/Grape-Shot.jpg>

Blood oath. That nice red head could 'pop my
cork', any day! ;)

But 'Jeroboam'?! OK, I gotta' rule out reaching
into Hebrew for the 'new words' category. I *was*
referring to words that are (technically incorporated
into, or derived from) English.

( Considers how little of English is based in
ancient English languages, as opposed to Latin,
the Germanic or Nordic languages, French.. )

OK, OK.. it qualifies. ;)

Good one. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top