void init_www() { raptor_www_init(); fabl_raptor_www = raptor_www_new(); raptor_www_set_user_agent(fabl_raptor_www,"Fabl"); raptor_www_set_write_bytes_handler(fabl_raptor_www,fabl_raptor_www_write_bytes,NULL); raptor_www_set_error_handler(fabl_raptor_www,raptorMessageHandler,NULL); }
int main (int argc, char *argv[]) { const char *program = raptor_basename(argv[0]); raptor_world *world; const char *uri_string; raptor_www *www; const char *user_agent = "raptor_www_test/0.1"; raptor_uri *uri; void *string = NULL; size_t string_length = 0; if(argc > 1) uri_string = argv[1]; else uri_string = "http://librdf.org/"; world = raptor_new_world(); if(!world || raptor_world_open(world)) exit(1); uri = raptor_new_uri(world, (const unsigned char*)uri_string); if(!uri) { fprintf(stderr, "%s: Failed to create Raptor URI for %s\n", program, uri_string); exit(1); } www = raptor_new_www(world); raptor_www_set_content_type_handler(www, write_content_type, (void*)stderr); raptor_www_set_user_agent(www, user_agent); /* start retrieval (always a GET) */ if(raptor_www_fetch_to_string(www, uri, &string, &string_length, malloc)) { fprintf(stderr, "%s: WWW fetch failed\n", program); } else { #if defined(RAPTOR_DEBUG) && RAPTOR_DEBUG > 1 fprintf(stderr, "%s: HTTP response status %d\n", program, www->status_code); fprintf(stderr, "%s: Returned %d bytes of content\n", program, (int)string_length); #endif } if(string) free(string); raptor_free_www(www); raptor_free_uri(uri); raptor_free_world(world); return 0; }
int main (int argc, char *argv[]) { const char *uri_string; raptor_www *www; const char *user_agent="raptor-www-test"; raptor_uri *uri; void *string=NULL; size_t string_length=0; if(argc>1) uri_string=argv[1]; else uri_string="http://librdf.org/"; raptor_uri_init(); raptor_www_init(); uri=raptor_new_uri((const unsigned char*)uri_string); if(!uri) { fprintf(stderr, "Failed to create Raptor URI for %s\n", uri_string); exit(1); } www=raptor_www_new(); raptor_www_set_content_type_handler(www, write_content_type, (void*)stderr); raptor_www_set_user_agent(www, user_agent); /* start retrieval (always a GET) */ if(raptor_www_fetch_to_string(www, uri, &string, &string_length, malloc)) { printf("WWW fetch failed\n"); } else { printf("HTTP response status %d\n", www->status_code); printf("Returned %d bytes of content\n", (int)string_length); } if(string) free(string); raptor_www_free(www); raptor_free_uri(uri); raptor_www_finish(); return 0; }