Fix error with --save-headers

Hrvoje Niksic <[email protected]> Sat, 18 Jun 2005 16:12:43 +0200
Newsgroups gmane.comp.web.wget.patches
Message-ID <[email protected]>
--save-headers is broken by freeing "head" prematurely.  Here is a
fix:

2005-06-18  Hrvoje Niksic  <[email protected]>

	* http.c (gethttp): Don't free "head" before using it to save
	headers.

Index: src/http.c
===================================================================
RCS file: /pack/anoncvs/wget/src/http.c,v
retrieving revision 1.192
diff -u -r1.192 http.c
--- src/http.c	2005/06/17 22:06:26	1.192
+++ src/http.c	2005/06/18 14:12:17
@@ -1753,7 +1753,6 @@
 	contrange = first_byte_pos;
     }
   resp_free (resp);
-  xfree (head);
 
   /* 20x responses are counted among successful by default.  */
   if (H_20X (statcode))
@@ -1945,6 +1944,9 @@
      size.  Maybe we should save some additional information?  */
   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;