next up previous contents index
Next: Example Up: Accessing Internet with Libwww Previous: RDF parsing.   Contents   Index

Status Code

Finally, Status is bound to an integer that represents the return code from the HTTP request. A complete list of return codes is given in XSB/prolog_includes/http_errors.h. If you need to refer to error codes in your Prolog application, it is advisable to use symbolic notation (e.g., HT_TIMEOUT) rather than specific numbers (e.g., -905). To make this happen, put the following lines at the top of your program:

    :- compiler_options([xpp_on]).
    #include "http_errors.h"
The Libwww package also includes a predicate, http_liberr/3, that is convenient for providing English language explanations to the errors:
    :- import http_liberr/3 from usermod.
The first argument of this predicate is the status code returned by an earlier call to Libwww_request, the second is an English explanation of the status, and the last is an atom that describes the class of the error (e.g., internal, server error, client error, etc.). For full details see XSB/packages/libwww/http_liberr.P. Note that the status code for a successful call is HT_LOADED (=200), not 0 or 1!



Luis Fernando P. de Castro 2003-06-27