diff --git a/src/ChangeLog b/src/ChangeLog
index 756178e7..2b62712d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2005-06-18  Hrvoje Niksic  <hniksic@xemacs.org>
+
+	* http.c (gethttp): Don't free "head" before using it to save
+	headers.
+
 2005-06-18  Hrvoje Niksic  <hniksic@xemacs.org>
 
 	* http.c (gethttp): When -E is in use, check for file existence
diff --git a/src/http.c b/src/http.c
index 263a26fd..69760e7a 100644
--- a/src/http.c
+++ b/src/http.c
@@ -1753,7 +1753,6 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
 	contrange = first_byte_pos;
     }
   resp_free (resp);
-  xfree (head);
 
   /* 20x responses are counted among successful by default.  */
   if (H_20X (statcode))
@@ -1946,6 +1945,9 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy)
   if (opt.save_headers)
     fwrite (head, 1, strlen (head), fp);
 
+  /* Now we no longer need to store the response header. */
+  xfree (head);
+
   /* Download the request body.  */
   flags = 0;
   if (keep_alive)