Add http_header_t->magic

Add magic field since http_header_t is held as a void pointer in a list_t
and always cast blindly.

Issue: 50189
diff --git a/src/common/http.c b/src/common/http.c
index 963b12c..cd68e92 100644
--- a/src/common/http.c
+++ b/src/common/http.c
@@ -414,8 +414,10 @@
 
 extern void free_http_header(http_header_t *header)
 {
+	xassert(header->magic == HTTP_HEADER_MAGIC);
 	xfree(header->name);
 	xfree(header->value);
+	header->magic = ~HTTP_HEADER_MAGIC;
 	xfree(header);
 }
 
@@ -426,6 +428,7 @@
 	const char *key = y;
 
 	xassert(entry->name);
+	xassert(entry->magic == HTTP_HEADER_MAGIC);
 
 	if (key == NULL)
 		return 0;
@@ -448,8 +451,10 @@
 						   _http_header_find_key,
 						   (void *) name);
 
-	if (header)
+	if (header) {
+		xassert(header->magic == HTTP_HEADER_MAGIC);
 		return header->value;
-	else
-		return NULL;
+	}
+
+	return NULL;
 }
diff --git a/src/common/http.h b/src/common/http.h
index f42e100..1d2aa4b 100644
--- a/src/common/http.h
+++ b/src/common/http.h
@@ -209,8 +209,11 @@
 /* Copy all members in URL */
 extern void url_copy_members(url_t *dst, const url_t *src);
 
+#define HTTP_HEADER_MAGIC 0x1aaffbe2
+
 /* HTTP header */
 typedef struct {
+	int magic; /* HTTP_HEADER_MAGIC */
 	char *name;
 	char *value;
 } http_header_t;
diff --git a/src/slurmrestd/http.c b/src/slurmrestd/http.c
index 6ef273e..1086702 100644
--- a/src/slurmrestd/http.c
+++ b/src/slurmrestd/http.c
@@ -242,6 +242,7 @@
 
 	/* Add copy to list of headers */
 	entry = xmalloc(sizeof(*entry));
+	entry->magic = HTTP_HEADER_MAGIC;
 	entry->name = xstrdup(header->name);
 	entry->value = xstrdup(header->value);
 	list_append(request->headers, entry);
@@ -527,6 +528,7 @@
 		list_itr_t *itr = list_iterator_create(args->headers);
 		http_header_t *header = NULL;
 		while ((header = list_next(itr))) {
+			xassert(header->magic == HTTP_HEADER_MAGIC);
 			if ((rc = _write_fmt_header(args->con, header->name,
 						    header->value)))
 				break;
diff --git a/src/slurmrestd/operations.c b/src/slurmrestd/operations.c
index da9f220..1520aac 100644
--- a/src/slurmrestd/operations.c
+++ b/src/slurmrestd/operations.c
@@ -236,6 +236,7 @@
 		.body_length = (err ? strlen(err) : 0),
 	};
 	http_header_t close = {
+		.magic = HTTP_HEADER_MAGIC,
 		.name = "Connection",
 		.value = "Close",
 	};