gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r580 - GNUnet/src/applications/bootstrap_http


From: grothoff
Subject: [GNUnet-SVN] r580 - GNUnet/src/applications/bootstrap_http
Date: Sat, 2 Apr 2005 17:33:56 -0800 (PST)

Author: grothoff
Date: 2005-04-02 17:33:51 -0800 (Sat, 02 Apr 2005)
New Revision: 580

Modified:
   GNUnet/src/applications/bootstrap_http/http.c
Log:
GNUnet svn, support "http://hostname:8081/directory/hostlist"; type of 
HOSTLISTURL


From: 
Nicklas Larsson <address@hidden>


To: 
Christian Grothoff <address@hidden>


Date: 
Today 19:35:17

 

 src/applications/bootstrap_http/http.c

 --
    url[curpos] = '\0'; /* terminator for hostname */
    --
       curpos = 0;
          while ( (curpos < strlen(hostname)) &&
                    (hostname[curpos] != ':') )
                         curpos++;
                            if (curpos == strlen(hostname))
                                 port = TCP_HTTP_PORT;
                                      else
                                           port = 
atoi(STRDUP(&hostname[curpos+1]));

                                              hostname[curpos] = '\0'; /* 
terminator for hostname */
                                              --
                                                 sock = SOCKET(PF_INET, 
SOCK_STREAM, 0);
                                                 --

                                                 sorry for not providing a 
diff, hope its ok anyway.. (i really dont know 
                                                 if its RFC, but i use it)

                                                 /larsson



Modified: GNUnet/src/applications/bootstrap_http/http.c
===================================================================
--- GNUnet/src/applications/bootstrap_http/http.c       2005-04-02 18:14:36 UTC 
(rev 579)
+++ GNUnet/src/applications/bootstrap_http/http.c       2005-04-03 01:33:51 UTC 
(rev 580)
@@ -32,7 +32,7 @@
 
 #define TCP_HTTP_PORT 80
 #define HTTP_URL "http://";
-#define GET_COMMAND "GET http://%s%s HTTP/1.0\r\n\r\n"
+#define GET_COMMAND "GET http://%s:%u%s HTTP/1.0\r\n\r\n"
 
 /**
  * The HTTP proxy (optional)
@@ -82,6 +82,17 @@
     filename = STRDUP(&url[curpos]);
   url[curpos] = '\0'; /* terminator for hostname */
 
+  curpos = 0;
+  while ( (curpos < strlen(hostname)) &&
+          (hostname[curpos] != ':') )
+    curpos++;
+  if (curpos == strlen(hostname))
+    port = TCP_HTTP_PORT;
+  else
+    port = atoi(STRDUP(&hostname[curpos+1]));
+  
+  hostname[curpos] = '\0'; /* terminator for hostname */
+  
   sock = SOCKET(PF_INET, SOCK_STREAM, 0);
   if (sock < 0) {
     LOG(LOG_ERROR,
@@ -107,7 +118,7 @@
     soaddr.sin_addr.s_addr
       = ((struct in_addr*)(ip_info->h_addr))->s_addr;
     soaddr.sin_port
-      = htons(TCP_HTTP_PORT);
+      = htons(port);
   } else {
     soaddr.sin_addr.s_addr
       = theProxy.sin_addr.s_addr;
@@ -130,12 +141,13 @@
     return;
   }
 
-  n = strlen(filename) + strlen(GET_COMMAND) + strlen(hostname) + 1;
+  n = strlen(filename) + strlen(GET_COMMAND) + strlen(hostname) + 10;
   command = MALLOC(n);
   SNPRINTF(command,
           n,
           GET_COMMAND,
           hostname,
+          port,
           filename);
   FREE(filename);
   curpos = strlen(command)+1;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]