This is the list of small examples using the very basic features of the
Library. If you have not already compiled the library then please read the Installation guide before you continue. If you
want more details of how to use the Library then please read the User's Guide.
In the example we assume that the compiler knows where to look for libwww
include files and the binary library itself. If you are using the GNU
autoconf configure script then the examples are built as part of the overall
package. On other platforms, you must provide
the make file on your own.
This is an example of how you can add streams and then get the desired result.
The example shows how to add a content length counter stream and get the
result back.
Load a document and dump to local File
We here show how to fetch a document using HTTP and to save it to local file.
You must specify a local file name on the command line. There are two versions
of this program: The preemptive version with
no event loop and the non-preemptive version
for integration with Windows' event and other event loops.
Range requests can be used to ask for a part or for several parts of a
document from an HTTP server without asking for the whole thing. The output is
sent directly to stdout. Run the program without parameters for instructions.
Lets you save a document to an HTTP server. Note that both input and output is
a Web address (URI) so you can save a document from anywhere to anywhere.
Here are some sample apps that show how to use libwww together with James Clark's expat XML parser
and John Punin's integration of the SiRPAC RDF parser in libwww. See the XML module for more information
Although libwww is primarily for clients, it is in fact symmetric in that
it can handle both client requests and server requests. The way this is
handled is that each protocol is registered
with both a client handler and a server handler - depending on which type of
request you use, one of them is called. Note that in order to be able to serve
any document, there actually have to be a server handler. Currently, libwww
only comes with a raw socket loader which
isn't much of a server.
Libwww is designed using a "coke machine model", in other words using
asynchronous requests for most of its operations. For GET and
HEAD requests you can also use synchronous requests, but they are not
as flexible and requires more care.
You can also have a look at the more complete sample applications which are
capable of doing more interesting things. If you have any example code that
you would like to share with us then please
send us a mail so that we can add it to this page.