the --dump-header option now only creates the file when it needs to, not any
sooner
This commit is contained in:
Родитель
739b3f241d
Коммит
e3ef8b66a1
14
src/main.c
14
src/main.c
|
@ -859,6 +859,7 @@ int main(int argc, char *argv[])
|
||||||
char errorbuffer[URLGET_ERROR_SIZE];
|
char errorbuffer[URLGET_ERROR_SIZE];
|
||||||
|
|
||||||
struct OutStruct outs;
|
struct OutStruct outs;
|
||||||
|
struct OutStruct heads;
|
||||||
|
|
||||||
char *url = NULL;
|
char *url = NULL;
|
||||||
#ifdef GLOBURL
|
#ifdef GLOBURL
|
||||||
|
@ -1086,14 +1087,12 @@ int main(int argc, char *argv[])
|
||||||
/* open file for output: */
|
/* open file for output: */
|
||||||
if(strcmp(config.headerfile,"-"))
|
if(strcmp(config.headerfile,"-"))
|
||||||
{
|
{
|
||||||
headerfilep=(FILE *) fopen(config.headerfile, "wb");
|
heads.filename = config.headerfile;
|
||||||
if (!headerfilep) {
|
headerfilep=NULL;
|
||||||
helpf("Can't open '%s'!\n", config.headerfile);
|
|
||||||
return URG_WRITE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
headerfilep=stdout;
|
headerfilep=stdout;
|
||||||
|
heads.stream = headerfilep;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(outs.stream && isatty(fileno(outs.stream)) &&
|
if(outs.stream && isatty(fileno(outs.stream)) &&
|
||||||
|
@ -1147,7 +1146,7 @@ int main(int argc, char *argv[])
|
||||||
URGTAG_CRLF, config.crlf,
|
URGTAG_CRLF, config.crlf,
|
||||||
URGTAG_QUOTE, config.quote,
|
URGTAG_QUOTE, config.quote,
|
||||||
URGTAG_POSTQUOTE, config.postquote,
|
URGTAG_POSTQUOTE, config.postquote,
|
||||||
URGTAG_WRITEHEADER, headerfilep,
|
URGTAG_WRITEHEADER, &heads,
|
||||||
URGTAG_COOKIEFILE, config.cookiefile,
|
URGTAG_COOKIEFILE, config.cookiefile,
|
||||||
URGTAG_SSLVERSION, config.ssl_version,
|
URGTAG_SSLVERSION, config.ssl_version,
|
||||||
URGTAG_TIMECONDITION, config.timecond,
|
URGTAG_TIMECONDITION, config.timecond,
|
||||||
|
@ -1165,6 +1164,9 @@ int main(int argc, char *argv[])
|
||||||
/* it wasn't directed to stdout or stderr so close the file! */
|
/* it wasn't directed to stdout or stderr so close the file! */
|
||||||
fclose(config.errors);
|
fclose(config.errors);
|
||||||
|
|
||||||
|
if(!headerfilep && heads.stream)
|
||||||
|
fclose(heads.stream);
|
||||||
|
|
||||||
if(urlbuffer)
|
if(urlbuffer)
|
||||||
free(urlbuffer);
|
free(urlbuffer);
|
||||||
if (config.outfile && outs.stream)
|
if (config.outfile && outs.stream)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче