Cryptography Reference
In-Depth Information
to be passed in, as most HTTP proxies are, or at least can be, authenticating.
The standard format for a proxy specifi cation is
http://[username:password@]hostname[:port]/
where hostname is the only part that's required. Modify your main routine
as shown in Listing 1-8 to accept an optional proxy parameter, preceded by -p .
client
proxy
server
Connect (e.g., on port 8080)
GET http://www.server.com/somedocument.html HTTP/1.1
resolve www.server.com, connect to it (on port 80)
GET /somedocument.html HTTP/1.1
HTTP/1.1 200 OK
HTTP/1.1 200 OK
Figure 1-2: HTTP Proxies
Listing 1-8: “http.c” main (with proxy support)
int main( int argc, char *argv[ ] )
{
int client_connection;
char *proxy_host, *proxy_user, *proxy_password;
int proxy_port;
char *host, *path;
struct hostent *host_name;
struct sockaddr_in host_address;
int ind;
#ifdef WIN32
WSADATA wsaData;
#endif
if ( argc < 2 )
{
fprintf( stderr,
“Usage: %s: [-p http://[username:password@]proxy-host:proxy-port]\
<URL>\n”,
argv[ 0 ] );
return 1;
}
proxy_host = proxy_user = proxy_password = host = path = NULL;
ind = 1;
if ( !strcmp( “-p”, argv[ ind ] ) )
{
if ( !parse_proxy_param( argv[ ++ind ], &proxy_host, &proxy_port,
(Continued)
 
Search WWH ::




Custom Search