[redland-dev] Proxy Settings for Raptor...

Dave Beckett dave.beckett at bristol.ac.uk
Tue Jun 14 17:14:47 BST 2005


On Tue, 14 Jun 2005 11:52:58 -0400, <xxxext-sapna.dixit at nokia.com> wrote:

> Hello All,
> 
> I am new to using Raptor.  I would like to parse URI's using
> Raptor, however, my company has a firewall disallowing me from
> doing so directly.  I know the proxy host and port to use but I am
> unsure as to which file in the Raptor package I need to alter in
> order to change the default settings.  If anyone has any idea how
> to set proxies on Raptor, please let me know.

Raptor relies on other libraries to do fetching of URIs.  I think
both curl and libxml respect the standard system environment
variables HTTP_PROXY and FTP_PROXY.  I've no idea what you
use for SOCKS, maybe try those first.  You shouldn't need to change
that code.


However, if you are using raptor alone, then you can use the
raptor_www API to set the proxy as a parameter with

  raptor_www *www = raptor_www_new();
  raptor_www_set_proxy(www, "http://yourproxy.com/");

and instead of raptor_parse_uri use this code which is the
core of raptor_parse_uri:

  raptor_www_set_write_bytes_handler(www, write_bytes, rdf_parser);

  rc=raptor_start_parse(rdf_parser, base_uri);
  // ... error checking ...

  rc= raptor_www_fetch(www, fetch_uri);
  // ... error checking ...

  raptor_parse_chunk(rdf_parser, NULL, 0, 1);

  raptor_www_free(www);

where write_bytes is something like:

  void write_bytes(raptor_www* www, void *userdata, const void *ptr,
		   size_t size, size_t nmemb) {
    if(raptor_parse_chunk(userdata, ptr, size * nmemb, 0))
      raptor_www_abort(www, "Parsing failed");
  }


Alternatively #3, if you want real fine control of all the WWW
retrieval parameters such as caching, socksing, you could build your
own CURL handle and use
   raptor_www *raptor_www_new_with_connection(void* connection);

which gives you a raptor_www object for the CURL handle, replacing
raptor_www_new();  At present only the CURL backend uses this
connection object.

Then follow the rest of the code above.

Dave


More information about the redland-dev mailing list