Re: saving a URL
Gecse Roland writes:
> On Mon, 20 May 1996, James Gallagher wrote:
> Sacha wrote:
> > /* before I added this next line it wouldn't write */
> > HTRequest_setOutputFormat(request, WWW_SOURCE);
> Of course it wouldn't write, because you have to set the output format
> according to the libwww interface you'll use.
> I hope I was right -- Henrik?,
Yep - you are on the right track!
Just to summarize - libwww has a small set of "internal" media types
(content types) which do not correspond to any "real" type. The WWW_SOURCE
and WWW_PRESENT are both examples of this. WWW_SOURCE is a define for "*/*"
which is a way of saying any 'media type of type "*" and subtype "*"' or in
orther words: we ask libwww to pass the exact same format to the application
as it gets in from the network.
WWW_PRESENT is a type representing the output format that the end user sees
on the screen, for example. We could also call it WWW_CANVAS. Only "200 OK"
responses are passed to this output. That is, WWW_PRESENT will never have to
deal with error messages etc.
However, in some cases, HTTP servers can send back "error documents" for
example if there are multiple choices of a document. Libwww defined
WWW_DEBUG to handle these error documents. WWW_DEBUG is very similar to
WWW_PRESENT in that it may present something to the end user - it is just
the content of the document that differs.
The default output format is set to WWW_PRESENT but it is a common problem
to confuse the default output format - would it be easier if we set the
default output format to WWW_SOURCE instead?
> The stream stack will be initialized using that format type as its tail,
> and then it tries to figure out the appropriate converters.
> The WWW_SOURCE uses an unstructured stream, so the converters you've
> initialized are enough to do the work. But when you would choose
> WWW_PRESENT which belongs to the HText structured stream, you'd have to
> make the HText_* functions!
One thing that is importan to note is that the
*** The application defines the binding between a media type and a stream to
handle the data***
Hence, libwww does _not_ know what WWW_PRESENT or WWW_DEBUG points to. The
library comes with a default set of streams that can be used - a default
HTML parser etc. but these are not part of libwww core as such. They are in
fact on the realm of the application. If WWW_PRESENT does not point to
anything at all, for example, then libwww decides to dump the data to local
Henrik Frystyk Nielsen, <firstname.lastname@example.org>
World-Wide Web Consortium, MIT/LCS NE43-356
545 Technology Square, Cambridge MA 02139, USA