W3C home > Mailing lists > Public > www-lib@w3.org > July to September 2000

Re: <----- ok, now I'm admitting it. I'm dumb.

From: Peter Stamfest <peter.stamfest@eunet.at>
Date: Fri, 8 Sep 2000 07:47:01 +0200 (CEST)
To: James Hicks <jhicks@outpost.net.au>
cc: www-lib@w3.org
Message-ID: <Pine.LNX.4.21.0009080729030.8066-100000@peter.stamf.pr.at>


No, you are not:

On Fri, 8 Sep 2000, James Hicks wrote:

> Date: Fri, 8 Sep 2000 16:10:44 +1100
> From: James Hicks <jhicks@outpost.net.au>
> To: www-lib@w3c.org
> Subject: <----- ok, now I'm admitting it. I'm dumb.
> Resent-Date: Fri, 8 Sep 2000 01:12:20 -0400 (EDT)
> Resent-From: www-lib@w3.org
> I can face facts. This is insane. Now I can get head.c to compile and run,
> but I'll be absolutely blowed if I can work out where that source PUTS the
> headers. All I need to do is get the content-length header for a given URL.
> I follow the source code but it seems to be an endless stream of routines
> calling other routines. I can also find no documentation whatsoever related
> to GETTING headers and doing things with them. SETTING headers yes, for
> requests and suchlike, and there are demonstration programs that GET headers
> but don't display them or seem to do anything with them, demonstration
> programs that get headers AND bodys and display both (wont help me much with
> 30meg files), and demonstration programs that get bodies without headers and
> display that... but nothing that gets a header and displays and/or does
> anything with it. I'm lost. I'm stupid. I'm Australian. I thought I knew C.
> I write C programs all the time but they never look like this, why is it so
> hard to get one little header?

This seems to be a normal reaction. Me first attempts ended like yours,
but I start to get some understanding of things (and I keep finding
inconsistencies, stupid things and the like, you may have noticed that I
produce a lot of patches these days).

Something is worrying me about the library. I'm still worried if I can
trust it. I reacted to this by doing a lot of testing...

OK, here are my 2 cents regarding your problem:

The content-length (if sent in the header) can be queried by calling
HTAnchor_length(anchor) after a successful loading of a request (you might
do this in an after handler.

If you are interested in other headers, there are some routines in
HTAnchor.c (HTAnchor.html for documentation), or you can use
HTAnchor_headers (for successful loadings) or use HTResponse_headers
(if unsuccessful) to obtain a HTAssocList:
Here is a code snippet (that could be much improved...) to give you an
idea (it prints all the header information there is):

    HTList *h;
    HTAssoc *assoc;

    h = HTResponse_header(HTRequest_response(data->request));
    if (h == NULL) 
	h = HTAnchor_header(data->anchor);

    while ((assoc = (HTAssoc*)HTAssocList_nextObject(h)) != NULL) {
	fprintf(stderr, "%s -> %s\n", 
		HTAssoc_name(assoc), HTAssoc_value(assoc));

Please be warned, that in the library as currently distributed, 
headers are subject to change by library routines. I posted a patch
yesterday (i think) that keeps the headers intact. 

You should, however, use existing routines if you want to access
"standard" information!!

> <mumbling continues, punctuated by head banging against desk>

Let me repeat one thing: After some time, you actually get an
understanding of how the library works, however I had to look at its
source code. So there is definitely a documentation problem. A
documentation project would be nice. 

Even nicer would be to move the whole thing to C++, because then the
object orientation would finally work. The current object model is quite
nice, but it is hard to use it. I think it is harder to use than the
X-toolkit, and that one is quite tricky if you use it by hand. Moving to
C++, however, would probably mean to write the whole thing from scratch,
something I did not do, because it would probably have taken me longer
than to learn libwww in its current state. But one can dream...

Received on Friday, 8 September 2000 01:49:01 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:53 UTC