aboutsummaryrefslogtreecommitdiff
path: root/www/http_get/files/patch-http_get.c
blob: 219b0874d4ef25e8a12026e88d1a34a291770161 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
--- http_get.c.orig	Wed Dec 15 19:10:11 2004
+++ http_get.c	Wed Dec 15 19:10:30 2004
@@ -2,7 +2,9 @@
 **
 ** Originally based on a simple version by Al Globus <globus@nas.nasa.gov>.
 ** Debugged and prettified by Jef Poskanzer <jef@acme.com>.  Also includes
-** ifdefs to handle https via OpenSSL.
+** ifdefs to handle https via OpenSSL.  -h argument for debugging multihomed
+** URLs added by Jim Salter.
+**
 */
 
 #include <unistd.h>
@@ -35,6 +37,7 @@
 static int verbose;
 static int timeout;
 static char* url;
+static char* force_host;
 
 /* Protocol symbols. */
 #define PROTO_HTTP 0
@@ -72,6 +75,8 @@
     user_agent = "http_get";
     auth_token = (char*) 0;
     cookie = (char*) 0;
+    force_host = (char*) "[NONE]";
+
     while ( argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0' )
 	{
 	if ( strcmp( argv[argn], "-v" ) == 0 )
@@ -81,6 +86,11 @@
 	    ++argn;
 	    timeout = atoi( argv[argn] );
 	    }
+        else if ( strcmp( argv[argn], "-h" ) == 0 && argn + 1 < argc )
+            {
+            ++argn;
+            force_host = argv[argn];
+            }
 	else if ( strcmp( argv[argn], "-r" ) == 0 && argn + 1 < argc )
 	    {
 	    ++argn;
@@ -127,7 +137,7 @@
 static void
 usage()
     {
-    (void) fprintf( stderr, "usage:  %s [-t timeout] [-r referer] [-u user-agent] [-a username:password] url\n", argv0 );
+    (void) fprintf( stderr, "usage:  %s [-t timeout] [-h force host address] [-r referer] [-u user-agent] [-a username:password] url\n", argv0 );
     exit( 1 );
     }
 
@@ -218,7 +228,16 @@
     int bytes, b, header_state, status;
 
     (void) alarm( timeout );
-    sockfd = open_client_socket( host, port );
+
+if ( force_host == "[NONE]" )
+    {
+        sockfd = open_client_socket( host, port );
+    }
+else
+    {
+        sockfd = open_client_socket( force_host, port );
+    }
+
 
 #ifdef USE_SSL
     if ( protocol == PROTO_HTTPS )