Explorar o código

Auto-format after merge

bel %!s(int64=8) %!d(string=hai) anos
pai
achega
e7f48f31b2
Modificáronse 2 ficheiros con 36 adicións e 31 borrados
  1. 5 4
      include/civetweb.h
  2. 31 27
      src/civetweb.c

+ 5 - 4
include/civetweb.h

@@ -630,13 +630,14 @@ CIVETWEB_API void mg_send_mime_file(struct mg_connection *conn,
      mime_type: Content-Type for file.  NULL will cause the type to be
      mime_type: Content-Type for file.  NULL will cause the type to be
                 looked up by the file extension.
                 looked up by the file extension.
      additional_headers: Additional custom header fields appended to the header.
      additional_headers: Additional custom header fields appended to the header.
-                         Each header must start with an X- to ensure it is not included twice.
+                         Each header must start with an X- to ensure it is not
+   included twice.
                          NULL does not append anything.
                          NULL does not append anything.
 */
 */
 CIVETWEB_API void mg_send_mime_file2(struct mg_connection *conn,
 CIVETWEB_API void mg_send_mime_file2(struct mg_connection *conn,
-                                    const char *path,
-                                    const char *mime_type,
-                                    const char* additional_headers);
+                                     const char *path,
+                                     const char *mime_type,
+                                     const char *additional_headers);
 
 
 /* Store body data into a file. */
 /* Store body data into a file. */
 CIVETWEB_API long long mg_store_body(struct mg_connection *conn,
 CIVETWEB_API long long mg_store_body(struct mg_connection *conn,

+ 31 - 27
src/civetweb.c

@@ -7029,17 +7029,17 @@ handle_static_file_request(struct mg_connection *conn,
 	                range,
 	                range,
 	                encoding);
 	                encoding);
 
 
-    /* The previous code must not add any header starting with X- to make
-     * sure no one of the additional_headers is included twice */
-
-    if (additional_headers != NULL) {
-        (void)mg_printf(conn,
-                        "%.*s\r\n\r\n",
-                        (int)strlen(additional_headers),
-                        additional_headers);
-    } else {
-        (void)mg_printf(conn, "\r\n");
-    }
+	/* The previous code must not add any header starting with X- to make
+	 * sure no one of the additional_headers is included twice */
+
+	if (additional_headers != NULL) {
+		(void)mg_printf(conn,
+		                "%.*s\r\n\r\n",
+		                (int)strlen(additional_headers),
+		                additional_headers);
+	} else {
+		(void)mg_printf(conn, "\r\n");
+	}
 
 
 	if (strcmp(conn->request_info.request_method, "HEAD") != 0) {
 	if (strcmp(conn->request_info.request_method, "HEAD") != 0) {
 		send_file_data(conn, filep, r1, cl);
 		send_file_data(conn, filep, r1, cl);
@@ -7101,9 +7101,9 @@ mg_send_mime_file(struct mg_connection *conn,
 
 
 void
 void
 mg_send_mime_file2(struct mg_connection *conn,
 mg_send_mime_file2(struct mg_connection *conn,
-                  const char *path,
-                  const char *mime_type,
-                  const char* additional_headers)
+                   const char *path,
+                   const char *mime_type,
+                   const char *additional_headers)
 {
 {
 	struct file file = STRUCT_FILE_INITIALIZER;
 	struct file file = STRUCT_FILE_INITIALIZER;
 	if (mg_stat(conn, path, &file)) {
 	if (mg_stat(conn, path, &file)) {
@@ -7121,7 +7121,8 @@ mg_send_mime_file2(struct mg_connection *conn,
 				                "Error: Directory listing denied");
 				                "Error: Directory listing denied");
 			}
 			}
 		} else {
 		} else {
-			handle_static_file_request(conn, path, &file, mime_type, additional_headers);
+			handle_static_file_request(
+			    conn, path, &file, mime_type, additional_headers);
 		}
 		}
 	} else {
 	} else {
 		send_http_error(conn, 404, "%s", "Error: File not found");
 		send_http_error(conn, 404, "%s", "Error: File not found");
@@ -11942,21 +11943,24 @@ close_socket_gracefully(struct mg_connection *conn)
 	 * ephemeral port exhaust problem under high QPS. */
 	 * ephemeral port exhaust problem under high QPS. */
 	linger.l_onoff = 1;
 	linger.l_onoff = 1;
 	linger.l_linger = 1;
 	linger.l_linger = 1;
-	socklen_t error_code=0;
-	getsockopt(conn->client.sock, SOL_SOCKET, SO_ERROR, &error_code, (socklen_t *)sizeof(error_code));
-	if (error_code==ECONNRESET) {
+	socklen_t error_code = 0;
+	getsockopt(conn->client.sock,
+	           SOL_SOCKET,
+	           SO_ERROR,
+	           &error_code,
+	           (socklen_t *)sizeof(error_code));
+	if (error_code == ECONNRESET) {
 		/* Socket already closed by client/peer, close socket without linger */
 		/* Socket already closed by client/peer, close socket without linger */
-	}
-	else{
+	} else {
 		if (setsockopt(conn->client.sock,
 		if (setsockopt(conn->client.sock,
-					   SOL_SOCKET,
-					   SO_LINGER,
-					   (char *)&linger,
-					   sizeof(linger)) != 0) {
+		               SOL_SOCKET,
+		               SO_LINGER,
+		               (char *)&linger,
+		               sizeof(linger)) != 0) {
 			mg_cry(conn,
 			mg_cry(conn,
-				   "%s: setsockopt(SOL_SOCKET SO_LINGER) failed: %s",
-				   __func__,
-				   strerror(ERRNO));
+			       "%s: setsockopt(SOL_SOCKET SO_LINGER) failed: %s",
+			       __func__,
+			       strerror(ERRNO));
 		}
 		}
 	}
 	}