* gpgkeys_curl.c (main): New "follow-redirects" option. Takes an optional
authorDavid Shaw <dshaw@jabberwocky.com>
Wed, 22 Dec 2004 19:19:10 +0000 (19:19 +0000)
committerDavid Shaw <dshaw@jabberwocky.com>
Wed, 22 Dec 2004 19:19:10 +0000 (19:19 +0000)
numeric value for the maximum number of redirects to allow.  Defaults to
5.

* gpgkeys_curl.c (main), gpgkeys_finger.c (main), gpgkeys_hkp.c (main),
gpgkeys_http.c (main), gpgkeys_ldap.c (main): Make sure that a "timeout"
option passed with no arguments is properly handled.

keyserver/ChangeLog
keyserver/gpgkeys_curl.c
keyserver/gpgkeys_finger.c
keyserver/gpgkeys_hkp.c
keyserver/gpgkeys_http.c
keyserver/gpgkeys_ldap.c

index de8516d..deee410 100644 (file)
@@ -1,5 +1,14 @@
 2004-12-22  David Shaw  <dshaw@jabberwocky.com>
 
+       * gpgkeys_curl.c (main): New "follow-redirects" option.  Takes an
+       optional numeric value for the maximum number of redirects to
+       allow.  Defaults to 5.
+
+       * gpgkeys_curl.c (main), gpgkeys_finger.c (main), gpgkeys_hkp.c
+       (main), gpgkeys_http.c (main), gpgkeys_ldap.c (main): Make sure
+       that a "timeout" option passed with no arguments is properly
+       handled.
+
        * gpgkeys_curl.c (get_key, writer): New function to wrap around
        fwrite to avoid DLL access problem on win32.
 
index 1d206e0..1d75445 100644 (file)
@@ -123,6 +123,7 @@ main(int argc,char *argv[])
   char line[MAX_LINE];
   char *thekey=NULL;
   unsigned int timeout=DEFAULT_KEYSERVER_TIMEOUT;
+  long follow_redirects=5;
 
   console=stderr;
 
@@ -269,8 +270,19 @@ main(int argc,char *argv[])
            {
              if(no)
                timeout=0;
-             else
+             else if(start[7]=='=')
                timeout=atoi(&start[8]);
+             else if(start[7]=='\0')
+               timeout=DEFAULT_KEYSERVER_TIMEOUT;
+           }
+         else if(strncasecmp(start,"follow-redirects",16)==0)
+           {
+             if(no)
+               follow_redirects=0;
+             else if(start[16]=='=')
+               follow_redirects=atoi(&start[17]);
+             else if(start[16]=='\0')
+               follow_redirects=-1;
            }
 
          continue;
@@ -312,6 +324,14 @@ main(int argc,char *argv[])
       goto fail;
     }
 
+  if(follow_redirects)
+    {
+      curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1);
+      if(follow_redirects>0)
+       curl_easy_setopt(curl,CURLOPT_MAXREDIRS,follow_redirects);
+    }
+
+
   /* If it's a GET or a SEARCH, the next thing to come in is the
      keyids.  If it's a SEND, then there are no keyids. */
 
index 4467362..303e636 100644 (file)
@@ -502,8 +502,10 @@ main(int argc,char *argv[])
            {
              if(no)
                timeout=0;
-             else
+             else if(start[7]=='=')
                timeout=atoi(&start[8]);
+             else if(start[7]=='\0')
+               timeout=DEFAULT_KEYSERVER_TIMEOUT;
            }
 
          continue;
index 5065138..db1e7ea 100644 (file)
@@ -949,8 +949,10 @@ main(int argc,char *argv[])
            {
              if(no)
                timeout=0;
-             else
+             else if(start[7]=='=')
                timeout=atoi(&start[8]);
+             else if(start[7]=='\0')
+               timeout=DEFAULT_KEYSERVER_TIMEOUT;
            }
 
          continue;
index dad141f..76da9e0 100644 (file)
@@ -311,8 +311,10 @@ main(int argc,char *argv[])
            {
              if(no)
                timeout=0;
-             else
+             else if(start[7]=='=')
                timeout=atoi(&start[8]);
+             else if(start[7]=='\0')
+               timeout=DEFAULT_KEYSERVER_TIMEOUT;
            }
 
          continue;
index 97f3911..bc603e7 100644 (file)
@@ -1763,8 +1763,10 @@ main(int argc,char *argv[])
            {
              if(no)
                timeout=0;
-             else
+             else if(start[7]=='=')
                timeout=atoi(&start[8]);
+             else if(start[7]=='\0')
+               timeout=DEFAULT_KEYSERVER_TIMEOUT;
            }
 
          continue;