/* REGISTER BEFORE FILTERS ** ----------------------- ** The BEFORE filters handle proxies, caches, rule files etc. ** The filters are called in the order by which the are registered ** Not done automaticly - may be done by application! */ PUBLIC void HTBeforeInit (void) { HTNet_addBefore(HTCredentialsFilter, "http://*", NULL, HT_FILTER_LATE); HTNet_addBefore(HTPEP_beforeFilter, "http://*", NULL, HT_FILTER_LATE); HTNet_addBefore(HTRuleFilter, NULL, NULL, HT_FILTER_LATE); HTNet_addBefore(HTProxyFilter, NULL, NULL, HT_FILTER_LATE); }
/* ** Start and stop the cookie engine */ PUBLIC BOOL HTCookie_init (void) { if (!baking_cookies) { /* Register the SetCookie header parser */ HTHeader_addParser("Set-Cookie", NO, HTCookie_parseSetCookie); /* Register the cookie before and after filters */ HTNet_addBefore(HTCookie_beforeFilter, "http://*", NULL, HT_FILTER_MIDDLE); HTNet_addAfter(HTCookie_afterFilter, "http://*", NULL, HT_ALL, HT_FILTER_MIDDLE); baking_cookies = YES; return YES; } return NO; }
/* HTProxy_add ** ----------- ** Registers a proxy as the server to contact for a specific ** access method. `proxy' should be a fully valid name, like ** "http://proxy.w3.org:8001" but domain name is not required. ** If an entry exists for this access then delete it and use the ** ne one. Returns YES if OK, else NO */ PUBLIC BOOL HTProxy_add (const char * access, const char * proxy) { /* ** If this is the first time here then also add a before filter to handle ** proxy authentication and the normal AA after filter as well. ** These filters will be removed if we remove all proxies again. */ if (!proxies) { proxies = HTList_new(); HTNet_addBefore(HTAA_proxyBeforeFilter, NULL, NULL, HT_FILTER_MIDDLE); HTNet_addAfter(HTAuthFilter, NULL, NULL, HT_NO_PROXY_ACCESS, HT_FILTER_MIDDLE); HTNet_addAfter(HTAuthFilter, NULL, NULL, HT_PROXY_REAUTH, HT_FILTER_MIDDLE); } return add_object(proxies, access, proxy, NO, -1); }
/* HTProxy_addRegex ** ---------------- ** Registers a proxy as the server to contact for any URL matching the ** regular expression. `proxy' should be a fully valid name, like ** "http://proxy.w3.org:8001". ** If an entry exists for this access then delete it and use the ** new one. Returns YES if OK, else NO */ PUBLIC BOOL HTProxy_addRegex (const char * regex, const char * proxy, int regex_flags) { /* ** If this is the first time here then also add a before filter to handle ** proxy authentication and the normal AA after filter as well. ** These filters will be removed if we remove all proxies again. */ if (!proxies) { proxies = HTList_new(); HTNet_addBefore(HTAA_proxyBeforeFilter, NULL, NULL, HT_FILTER_MIDDLE); HTNet_addAfter(HTAuthFilter, NULL, NULL, HT_NO_PROXY_ACCESS, HT_FILTER_MIDDLE); HTNet_addAfter(HTAuthFilter, NULL, NULL, HT_PROXY_REAUTH, HT_FILTER_MIDDLE); } #ifdef HT_POSIX_REGEX return add_object(proxies, regex, proxy, YES, regex_flags); #else return add_object(proxies, regex, proxy, NO, -1); #endif }
PRIVATE void robot_profile (const char * AppName, const char * AppVersion) { /* If the Library is not already initialized then do it */ if (!HTLib_isInitialized()) HTLibInit(AppName, AppVersion); if (!converters) { converters = HTList_new(); /* Register the default set of converters including the HTML parser */ HTConverterInit(converters); HTMLInit(converters); /* Set the converters as global converters for all requests */ HTFormat_setConversion(converters); } if (!transfer_encodings) { transfer_encodings = HTList_new(); /* Register the default set of transfer encoders and decoders */ HTTransferEncoderInit(transfer_encodings); HTFormat_setTransferCoding(transfer_encodings); } if (!content_encodings) { content_encodings = HTList_new(); /* Register the default set of content encoders and decoders */ HTContentEncoderInit(content_encodings); if (HTList_count(content_encodings) > 0) HTFormat_setContentCoding(content_encodings); else { HTList_delete(content_encodings); content_encodings = NULL; } } /* Register the default set of transport protocols */ HTTransportInit(); /* Register the default set of application protocol modules */ HTProtocolInit(); /* Initialize suffix bindings for local files */ HTBind_init(); /* Set max number of sockets we want open simultanously */ HTNet_setMaxSocket(32); /* Register some default set of BEFORE and AFTER filters */ HTNet_addBefore(HTRuleFilter, NULL, NULL, HT_FILTER_MIDDLE); HTNet_addBefore(HTProxyFilter, NULL, NULL, HT_FILTER_MIDDLE); HTNet_addAfter(HTInfoFilter, NULL, NULL, HT_ALL, HT_FILTER_LATE); /* Get any proxy or gateway environment variables */ HTProxy_getEnvVar(); /* Register the default set of MIME header parsers */ HTMIMEInit(); /* Register the default set of file suffix bindings */ HTFileInit(); /* Register the default set of Icons for directory listings */ HTIconInit(NULL); /* Register some default messages and dialog functions */ if (HTAlert_interactive()) { HTAlert_add(HTError_print, HT_A_MESSAGE); HTAlert_add(HTConfirm, HT_A_CONFIRM); HTAlert_add(HTPrompt, HT_A_PROMPT); HTAlert_add(HTPromptPassword, HT_A_SECRET); HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW); } HTAlert_setInteractive(YES); }