char errorbuffer[URLGET_ERROR_SIZE];
struct OutStruct outs;
+ struct OutStruct heads;
char *url = NULL;
#ifdef GLOBURL
/* open file for output: */
if(strcmp(config.headerfile,"-"))
{
- headerfilep=(FILE *) fopen(config.headerfile, "wb");
- if (!headerfilep) {
- helpf("Can't open '%s'!\n", config.headerfile);
- return URG_WRITE_ERROR;
- }
+ heads.filename = config.headerfile;
+ headerfilep=NULL;
}
else
headerfilep=stdout;
+ heads.stream = headerfilep;
}
if(outs.stream && isatty(fileno(outs.stream)) &&
URGTAG_CRLF, config.crlf,
URGTAG_QUOTE, config.quote,
URGTAG_POSTQUOTE, config.postquote,
- URGTAG_WRITEHEADER, headerfilep,
+ URGTAG_WRITEHEADER, &heads,
URGTAG_COOKIEFILE, config.cookiefile,
URGTAG_SSLVERSION, config.ssl_version,
URGTAG_TIMECONDITION, config.timecond,
/* it wasn't directed to stdout or stderr so close the file! */
fclose(config.errors);
+ if(!headerfilep && heads.stream)
+ fclose(heads.stream);
+
if(urlbuffer)
free(urlbuffer);
if (config.outfile && outs.stream)