1 /* 2 3 W3C Sample Code Library libwww Proxies and Gateways 4 5 6 ! 7 Proxy and gateway Manager 8 ! 9 */ 10 11 /* 12 ** (c) COPYRIGHT MIT 1995. 13 ** Please first read the full copyright statement in the file COPYRIGH. 14 */ 15 16 /* 17 18 This module keeps a list of proxies and gateways to be contacted on a request 19 in stead of requesting it directly from the origin server. The module replaces 20 the old system of environment variables for gateways and proxies. However 21 for backward compatibility there is a function that reads the environment 22 variables at start up. Note that there is a difference between a proxy and 23 a gateway - the difference is the way the URL is set up in the 24 RequestLine of the HTTP request. If the original, full URL looks 25 like "http://www.w3.org/test.html" then the result will for 26 a proxy is "http://www.w3.org/test.html" and a gateway 27 "/www.w3.org/test.html" 28 29 The module is implemented by HTProxy.c, and it is 30 a part of the W3C Sample Code 31 Library. 32 */ 33 34 #ifndef HTPROXY_H 35 #define HTPROXY_H 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 #include "HTList.h" 42 43 /* 44 . 45 Registering a Proxy Server 46 . 47 48 A proxy server is registered with a corresponding access method, for example 49 http, ftp etc. The `proxy' parameter should be a fully 50 valid name, like http://proxy.w3.org:8001 but domain name is 51 not required. If an entry exists for this access then delete it and use the 52 new one. 53 */ 54 55 extern BOOL HTProxy_add (const char * access, const char * proxy); 56 57 /* 58 ( 59 Registering a Proxy Using Regular Expressions 60 ) 61 62 Registers a proxy as the server to contact for any URL matching the regular 63 expression. This requires that you have compiled with the 64 HT_POSIX_REGEX flag, see the installation 65 instructions. If you call this function without having compiled with 66 the HT_POSIX_REGEX flag then you will essentially get the non-regex 67 version. The name of the proxy should be a fully valid URL, like 68 "http://proxy.w3.org:8001". Returns YES if OK, else NO 69 */ 70 71 extern BOOL HTProxy_addRegex (const char * regex, 72 const char * proxy, 73 int regex_flags); 74 75 /* 76 ( 77 Deleting All Registered Proxies 78 ) 79 */ 80 81 extern BOOL HTProxy_deleteAll (void); 82 83 /* 84 85 The remove function removes all registered proxies. This is automatically 86 done in HTLibTerminate() 87 . 88 Registering a No Proxy Location 89 . 90 91 The noproxy list is a list of host names and domain names where 92 we don't contact a proxy even though a proxy is in fact registered for this 93 particular access method . When registering a noproxy item, you 94 can specify a specific port for this access method in which case it isvalid 95 only for requests to this port. If `port' is '0' then it applies to all ports 96 and if `access' is NULL then it applies to to all access methods. Examples 97 of host names are w3.org and www.close.com 98 */ 99 100 extern BOOL HTNoProxy_add (const char * host, const char * access, 101 unsigned port); 102 103 /* 104 ( 105 Registering a NoProxy Location Using Regular Expressions 106 ) 107 108 Registers a regular expression where URIs matching this expression should 109 go directly and not via a proxy. Examples: 110 http://<star>\.w3\.org and 111 http://www\.noproxy\.com/<star> (I use 112 <star> in order not interfere with C comments) This requires 113 that you have compiled with the HT_POSIX_REGEX flag, see the 114 installation instructions. If you call this 115 function without having compiled with the HT_POSIX_REGEX flag then 116 you will essentially get the non-regex version. 117 */ 118 119 extern BOOL HTNoProxy_addRegex (const char * regex, int regex_flags); 120 121 /* 122 ( 123 Delete all Noproxy Destinations 124 ) 125 */ 126 127 extern BOOL HTNoProxy_deleteAll (void); 128 129 /* 130 131 The remove function removes all entries in the list. This is automatically 132 done in HTLibTerminate() 133 ( 134 Inverse the meaning of the NoProxy list 135 ) 136 137 Allows to change the value of a flag so that the NoProxy list is interpreted 138 as if it were an OnlyProxy list. 139 */ 140 141 extern int HTProxy_NoProxyIsOnlyProxy (void); 142 extern void HTProxy_setNoProxyIsOnlyProxy (int value); 143 144 /* 145 . 146 Look for a Proxy server 147 . 148 149 This function evaluates the lists of registered proxies and if one is found 150 for the actual access method and it is not registered in the `noproxy' list, 151 then a URL containing the host to be contacted is returned to the caller. 152 This string must be freed be the caller. 153 */ 154 155 extern char * HTProxy_find (const char * url); 156 157 /* 158 . 159 Registering a gateway 160 . 161 162 A gateway is registered with a corresponding access method, for example 163 http, ftp etc. The `gate' parameter should be a fully valid 164 name, like http://gateway.w3.org:8001 but domain name is not 165 required. If an entry exists for this access then delete it and use the new 166 one. 167 */ 168 169 extern BOOL HTGateway_add (const char * access, const char * gate); 170 extern BOOL HTGateway_deleteAll (void); 171 172 /* 173 174 The remove function removes all registered proxies. This is automatically 175 done in HTLibTerminate() 176 . 177 Look for a Gateway 178 . 179 180 This function evaluates the lists of registered gateways and if one is found 181 for the actual access method then it is returned and must be freed by the 182 caller. 183 */ 184 185 extern char * HTGateway_find (const char * url); 186 187 /* 188 . 189 Backwards Compability with Environment Variables 190 . 191 192 This function maintains backwards compatibility with the old environment 193 variables and searches for the most common values: http, ftp, news, wais, 194 and gopher 195 */ 196 197 extern void HTProxy_getEnvVar (void); 198 199 /* 200 */ 201 202 #ifdef __cplusplus 203 } 204 #endif 205 206 #endif /* HTPROXY_H */ 207 208 /* 209 210 211 212 @(#) $Id$ 213 214 */ 215