Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Mime-Type applet - test

0 views
Skip to first unread message

Andrew Thompson

unread,
Nov 11, 2009, 6:23:08 PM11/11/09
to
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%3A%2F%2Fpscode.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%3A%2F%2Fpscode.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%3A%2F
%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%3A%2F
%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'.)

--
Andrew T.
pscode.org

Andrew Thompson

unread,
Nov 11, 2009, 7:47:52 PM11/11/09
to
On Nov 12, 10:23 am, Andrew Thompson <andrewtho...@gmail.com> wrote:
> 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.

--
Andrew T.
pscode.org

Andrew Thompson

unread,
Nov 11, 2009, 9:26:12 PM11/11/09
to
On Nov 12, 11:47 am, Andrew Thompson <andrewtho...@gmail.com> wrote:
> On Nov 12, 10:23 am, Andrew Thompson <andrewtho...@gmail.com> wrote:
>
> > There is a new mime-type check applet available.
>
> All it took was going public to discover the
> first bug! ...

OK. Fixed, I think.

New source/javadocs, binary & help pages uploaded.

--
Andrew T.
pscode.org

Steven Simpson

unread,
Nov 12, 2009, 2:30:29 AM11/12/09
to
Andrew Thompson wrote:
> 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'.
>

Why is that sensible? The UA is not required even to specify a
User-Agent field.

--
ss at comp dot lancs dot ac dot uk

John B. Matthews

unread,
Nov 12, 2009, 10:18:24 AM11/12/09
to
In article
<363f190b-4aaa-49f4...@12g2000pri.googlegroups.com>,
Andrew Thompson <andrew...@gmail.com> wrote:

> 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."

> * Tests.
[...]
<blush>


> John B. Matthews' AlphaComposite example JNLP
> <http://pscode.org/mime/applet.html?media.url=http%3A%2F
> %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>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Andrew Thompson

unread,
Nov 12, 2009, 6:01:45 PM11/12/09
to
On Nov 13, 2:18 am, "John B. Matthews" <nos...@nospam.invalid> wrote:
> ..> Why 503 Service Unavailable? Not that I see a better one:

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

--
Andrew T.

Andrew Thompson

unread,
Nov 12, 2009, 6:04:36 PM11/12/09
to

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.

--
Andrew T.
pscode.org

Roedy Green

unread,
Nov 12, 2009, 7:28:21 PM11/12/09
to
On Wed, 11 Nov 2009 15:23:08 -0800 (PST), Andrew Thompson
<andrew...@gmail.com> wrote, quoted or indirectly quoted someone
who said :

>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)

Andrew Thompson

unread,
Nov 12, 2009, 9:19:58 PM11/12/09
to
On Nov 13, 11:28 am, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:

> On Wed, 11 Nov 2009 15:23:08 -0800 (PST), Andrew Thompson
> <andrewtho...@gmail.com> wrote, quoted or indirectly quoted someone

> who said :
>
> >There is a new mime-type check applet available.
>
> 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.

--
Andrew T.
pscode.org

John B. Matthews

unread,
Nov 12, 2009, 9:56:58 PM11/12/09
to
In article
<9022d24d-4dc3-4a69...@y28g2000prd.googlegroups.com>,
Andrew Thompson <andrew...@gmail.com> wrote:

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.

Andrew Thompson

unread,
Nov 12, 2009, 11:10:52 PM11/12/09
to
On Nov 13, 1:56 pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
> In article
> <9022d24d-4dc3-4a69-b821-2eeb52794...@y28g2000prd.googlegroups.com>,
>  Andrew Thompson <andrewtho...@gmail.com> wrote:
...

> > 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.

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. ;)

--
Andrew T.

Lew

unread,
Nov 12, 2009, 11:16:57 PM11/12/09
to
John B. Matthews wrote:
>> ..I would add a dismal jeremiad ..

Andrew Thompson wrote:
> ... it is a long time since I've heard a new ...


> (non-technical) word or term used.

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

--
Lew

Andrew Thompson

unread,
Nov 13, 2009, 3:17:31 AM11/13/09
to
On Nov 13, 3:16 pm, Lew <no...@lewscanon.com> wrote:
>...

> 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. :-)

--
Andrew T.

Teraposa Lunodas

unread,
Nov 24, 2009, 8:25:19 AM11/24/09
to
0 new messages