/* ** Proxy and Gateway BEFORE filter ** ------------------------------- ** Checks for registerd proxy servers or gateways and sees whether this ** request should be redirected to a proxy or a gateway. Proxies have ** higher priority than gateways so we look for them first! ** For HTTP/1.0 and HTTP/1.1 we may only send a full URL (including the ** host portion) to proxy servers. Therefore, we tell the Library whether ** to use the full URL or the traditional HTTP one without the host part. */ PUBLIC int HTProxyFilter (HTRequest * request, void * param, int mode) { HTParentAnchor * anchor = HTRequest_anchor(request); char * addr = HTAnchor_physical(anchor); char * physical = NULL; if ((physical = HTProxy_find(addr))) { HTRequest_setFullURI(request, YES); /* For now */ HTRequest_setProxy(request, physical); HT_FREE(physical); #if 0 /* Don't paste the URLs together anymore */ StrAllocCat(physical, addr); HTAnchor_setPhysical(anchor, physical); #endif } else if ((physical = HTGateway_find(addr))) { /* ** A gateway URL is crated by chopping off any leading "/" to make the ** host into part of path */ char * path = HTParse(addr, "", PARSE_HOST + PARSE_PATH + PARSE_PUNCTUATION); char * gatewayed = HTParse((*path=='/') ? path+1 : path, physical, PARSE_ALL); HTAnchor_setPhysical(anchor, gatewayed); HT_FREE(path); HT_FREE(gatewayed); HTRequest_setFullURI(request, NO); HTRequest_deleteProxy(request); } else { HTRequest_setFullURI(request, NO); /* For now */ HTRequest_deleteProxy(request); } return HT_OK; }
/* Generate Outout ** =============== */ PRIVATE void WSRC_gen_html (HTStream * me, BOOL source_file) { if (me->par_value[PAR_DATABASE_NAME]) { char * shortname = NULL; int l; StrAllocCopy(shortname, me->par_value[PAR_DATABASE_NAME]); l = strlen(shortname); if ( l > 4 && !strcasecomp(shortname + l -4, ".src")) { shortname[l-4] = 0; /* Chop of .src -- boring! */ } START(HTML_TITLE); PUTS(shortname); PUTS(source_file ? " WAIS source file" : " index"); END(HTML_TITLE); START(HTML_H1); PUTS(shortname); PUTS(source_file ? " description" : " index"); END(HTML_H1); HT_FREE(shortname); /* memleak, henrik */ } START(HTML_DL); /* Definition list of details */ if (source_file) { START(HTML_DT); PUTS("Access link"); START(HTML_DD); if (me->par_value[PAR_IP_NAME] && me->par_value[PAR_DATABASE_NAME]) { char WSRC_address[256]; char *addr = HTAnchor_address((HTAnchor*) me->request->anchor); char *gate = HTGateway_find(addr); char *www_database = HTEscape(me->par_value[PAR_DATABASE_NAME], URL_XALPHAS); if (!gate) { sprintf(WSRC_address, "wais://%s%s%s/%s", me->par_value[PAR_IP_NAME], me->par_value[PAR_TCP_PORT] ? ":" : "", me->par_value[PAR_TCP_PORT] ? me->par_value[PAR_TCP_PORT] :"", www_database); HTStartAnchor(me->target, NULL, WSRC_address); PUTS("Direct access"); END(HTML_A); } else { sprintf(WSRC_address, "%s%s%s%s/%s", gate, me->par_value[PAR_IP_NAME], me->par_value[PAR_TCP_PORT] ? ":" : "", me->par_value[PAR_TCP_PORT] ? me->par_value[PAR_TCP_PORT] : "", www_database); HTStartAnchor(me->target, NULL, WSRC_address); PUTS("Through a gateway"); END(HTML_A); } HT_FREE(gate); HT_FREE(addr); HT_FREE(www_database); } else { give_parameter(me, PAR_IP_NAME); give_parameter(me, PAR_DATABASE_NAME); } } /* end if source_file */ if (me->par_value[PAR_MAINTAINER]) { START(HTML_DT); PUTS("Maintainer"); START(HTML_DD); PUTS(me->par_value[PAR_MAINTAINER]); } if (me->par_value[PAR_IP_NAME]) { START(HTML_DT); PUTS("Host"); START(HTML_DD); PUTS(me->par_value[PAR_IP_NAME]); } END(HTML_DL); if (me->par_value[PAR_DESCRIPTION]) { START(HTML_PRE); /* Preformatted description */ PUTS(me->par_value[PAR_DESCRIPTION]); END(HTML_PRE); } (*me->target->isa->_free)(me->target); return; } /* generate html */