Selaa lähdekoodia

SSL redirect must also redirect the query string

bel 10 vuotta sitten
vanhempi
commit
6deb63e1ab
1 muutettua tiedostoa jossa 8 lisäystä ja 3 poistoa
  1. 8 3
      src/civetweb.c

+ 8 - 3
src/civetweb.c

@@ -5735,9 +5735,14 @@ static void redirect_to_https_port(struct mg_connection *conn, int ssl_index)
         sockaddr_to_string(host, hostlen, &conn->client.lsa);
         sockaddr_to_string(host, hostlen, &conn->client.lsa);
     }
     }
 
 
-    mg_printf(conn, "HTTP/1.1 302 Found\r\nLocation: https://%s:%d%s\r\n\r\n",
-              host, (int) ntohs(conn->ctx->listening_sockets[ssl_index].
-                                lsa.sin.sin_port), conn->request_info.uri);
+    /* Send host, port, uri and (if it exists) ?query_string */
+    mg_printf(conn, "HTTP/1.1 302 Found\r\nLocation: https://%s:%d%s%s%s\r\n\r\n",
+              host,
+              (int) ntohs(conn->ctx->listening_sockets[ssl_index].lsa.sin.sin_port),
+              conn->request_info.uri,
+              (conn->request_info.query_string == NULL) ? "" : "?",
+              (conn->request_info.query_string == NULL) ? "" : conn->request_info.query_string
+              );
 }
 }