Browse Source

Fix bug 221 and bug 201: For 221, check return value from connection_add() when adding a rendezvous post connection. For 201, do not include a content-length 0 with a GET request.

svn:r5765
Nick Mathewson 20 years ago
parent
commit
2fda7140e8
1 changed files with 17 additions and 6 deletions
  1. 17 6
      src/or/directory.c

+ 17 - 6
src/or/directory.c

@@ -451,8 +451,12 @@ directory_initiate_command(const char *address, uint32_t addr,
       return;
       return;
     }
     }
 
 
+    if (connection_add(conn) < 0) {
+      warn(LD_NET,"Unable to add AP bridge to dirserver.");
+      connection_mark_for_close(conn);
+      return;
+    }
     conn->state = DIR_CONN_STATE_CLIENT_SENDING;
     conn->state = DIR_CONN_STATE_CLIENT_SENDING;
-    connection_add(conn);
     /* queue the command on the outbuf */
     /* queue the command on the outbuf */
     directory_send_command(conn, platform, purpose, resource,
     directory_send_command(conn, platform, purpose, resource,
                            payload, payload_len);
                            payload, payload_len);
@@ -580,11 +584,18 @@ directory_send_command(connection_t *conn, const char *platform,
   connection_write_to_buf(url, strlen(url), conn);
   connection_write_to_buf(url, strlen(url), conn);
   tor_free(url);
   tor_free(url);
 
 
-  tor_snprintf(request, sizeof(request),
-               " HTTP/1.0\r\nContent-Length: %lu\r\nHost: %s%s\r\n\r\n",
-           payload ? (unsigned long)payload_len : 0,
-           hoststring,
-           proxyauthstring);
+  if (!strcmp(httpcommand, "GET") && !payload) {
+    tor_snprintf(request, sizeof(request),
+                 " HTTP/1.0\r\nHost: %s%s\r\n\r\n",
+                 hoststring,
+                 proxyauthstring);
+  } else {
+    tor_snprintf(request, sizeof(request),
+                 " HTTP/1.0\r\nContent-Length: %lu\r\nHost: %s%s\r\n\r\n",
+                 payload ? (unsigned long)payload_len : 0,
+                 hoststring,
+                 proxyauthstring);
+  }
   connection_write_to_buf(request, strlen(request), conn);
   connection_write_to_buf(request, strlen(request), conn);
 
 
   if (payload) {
   if (payload) {