int main (int argc, char ** argv) { HTRequest * request; HTProfile_newPreemptiveClient("HTTPHeadApplication", "1.0"); request = HTRequest_new(); #if 0 /* Turn on TRACE so we can see what is going on */ HTSetTraceMessageMask("sop"); #endif /* We don't want any progress notifications */ HTAlert_setInteractive(NO); /* Parse the command line options */ if (argc >= 2) { char * url = argv[1]; /* Set the header field match (if any) */ if (argc >= 3) match = argv[2]; /* Need our own trace and print functions */ HTPrint_setCallback(printer); HTTrace_setCallback(tracer); /* Add our own filter to handle termination */ HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST); /* Set the output format to source and put output to stdout */ HTRequest_setOutputStream(request, HTFWriter_new(request, stdout, YES)); /* Start the load */ if (url && *url) { HTHeadAbsolute(url, request); /* wait until the request has finished */ HTEventList_loop (request); } else HTPrint("Bad parameters - please try again\n"); } else { HTPrint("Type the URL to perform a HEAD request on.\n"); HTPrint("\t%s <url> <header-prefix>\n", argv[0]); HTPrint("where <header-prefix> is the prefix of the header fields\n"); HTPrint("you want to see, for example 'content*. If no \'*\' is used'\n"); HTPrint("then an exact match is needed. Default value is all header fields'\n"); } HTRequest_delete(request); /* Delete the request object */ HTProfile_delete(); return 0; }
static char* url_to_local_file(const char* url) { HTRequest* request = NULL; #ifdef __CYGWIN__ char* tmpfile = sidl_String_concat3("cyg", tmpnam(NULL), ".dll"); #else char* tmpfile = sidl_String_concat3("lib", tmpnam(NULL), ".so"); #endif HTProfile_newPreemptiveClient("sidl_DLL", "1.0"); HTAlert_setInteractive(FALSE); request = HTRequest_new(); HTLoadToFile(url, request, tmpfile); HTRequest_delete(request); HTProfile_delete(); return tmpfile; }
/* ** Loads a URL to a local file */ int main (int argc, char ** argv) { HTRequest * request; HTProfile_newPreemptiveClient("TestApp", "1.0"); request = HTRequest_new(); if (argc == 3) { char * url = argv[1]; char * filename = argv[2]; if (url && *url && filename && *filename) HTLoadToFile(url, request, filename); else printf("Bad parameters - please try again\n"); } else { printf("Type the URL to fetch and the name of the local file to put it in\n"); printf("\t%s <url> <filename>\n", argv[0]); } HTRequest_delete(request); /* Delete the request object */ HTProfile_delete(); return 0; }