diff --git a/docs/cmdline-opts/out-null.md b/docs/cmdline-opts/out-null.md index 58e5508cdc..cca193e3af 100644 --- a/docs/cmdline-opts/out-null.md +++ b/docs/cmdline-opts/out-null.md @@ -5,7 +5,7 @@ Long: out-null Help: Discard response data into the void Category: output Added: 8.16.0 -Multi: boolean +Multi: per-URL See-also: - output - remote-name diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index ce55d5d8e8..d34c1fa2ee 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -141,7 +141,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) intptr_t fhnd; #endif - if(config->out_null) + if(outs->out_null) return bytes; #ifdef DEBUGBUILD diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h index abce5cc419..bd32ab2d42 100644 --- a/src/tool_cfgable.h +++ b/src/tool_cfgable.h @@ -340,7 +340,6 @@ struct OperationConfig { BIT(rm_partial); /* on error, remove partially written output files */ BIT(skip_existing); - BIT(out_null); /* WRITEFUNCTION into the void */ }; struct GlobalConfig { diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 700e213947..ad76c8d280 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -1311,10 +1311,13 @@ static ParameterError parse_output(struct OperationConfig *config, return PARAM_NO_MEM; /* fill in the outfile */ - err = getstr(&url->outfile, nextarg, DENY_BLANK); + if(nextarg) + err = getstr(&url->outfile, nextarg, DENY_BLANK); + else + url->outfile = NULL; url->useremote = FALSE; /* switch off */ url->outset = TRUE; - config->out_null = FALSE; /* switch off --out-null */ + url->out_null = !nextarg; return err; } @@ -1353,6 +1356,7 @@ static ParameterError parse_remote_name(struct OperationConfig *config, url->outfile = NULL; /* leave it */ url->useremote = toggle; url->outset = TRUE; + url->out_null = FALSE; return PARAM_OK; } @@ -1836,8 +1840,7 @@ static ParameterError opt_bool(struct OperationConfig *config, togglebit(toggle, &config->authtype, CURLAUTH_NTLM); break; case C_OUT_NULL: /* --out-null */ - config->out_null = toggle; - break; + return parse_output(config, NULL); case C_BASIC: /* --basic */ togglebit(toggle, &config->authtype, CURLAUTH_BASIC); break; diff --git a/src/tool_operate.c b/src/tool_operate.c index 6c4dd87a4a..e8dac9691d 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -1321,7 +1321,8 @@ static CURLcode single_transfer(struct OperationConfig *config, } } - if((urlnode->useremote || + outs->out_null = urlnode->out_null; + if(!outs->out_null && (urlnode->useremote || (per->outfile && strcmp("-", per->outfile)))) { result = setup_outfile(config, per, outs, skipped); if(result) diff --git a/src/tool_sdecls.h b/src/tool_sdecls.h index fc0c6a546e..3b01f5592a 100644 --- a/src/tool_sdecls.h +++ b/src/tool_sdecls.h @@ -74,6 +74,7 @@ struct OutStruct { BIT(is_cd_filename); BIT(s_isreg); BIT(fopened); + BIT(out_null); }; /* @@ -95,6 +96,7 @@ struct getout { BIT(useremote); /* use remote filename locally */ BIT(noupload); /* if set, -T "" has been used */ BIT(noglob); /* disable globbing for this URL */ + BIT(out_null); /* discard output for this URL */ }; /* * 'trace' enumeration represents curl's output look'n feel possibilities. diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index d8d0ec5db5..cc3ea533d5 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -108,7 +108,7 @@ test718 test719 test720 test721 test722 test723 test724 test725 test726 \ test727 test728 test729 test730 test731 test732 test733 test734 test735 \ test736 test737 test738 test739 test740 test741 test742 test743 test744 \ test745 test746 test747 test748 test749 test750 test751 test752 test753 \ -test754 test755 \ +test754 test755 test756 \ test780 test781 test782 test783 test784 test785 test786 test787 test788 \ test789 test790 test791 test792 test793 \ \ diff --git a/tests/data/test756 b/tests/data/test756 new file mode 100644 index 0000000000..a205c19772 --- /dev/null +++ b/tests/data/test756 @@ -0,0 +1,80 @@ + + + +HTTP + + + +# Server-side + + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Response: 1 +Content-Type: text/html +Content-Length: 8 + +Hello1! + + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Response: 2 +Content-Type: text/html +Content-Length: 8 + +Hello2! + + + +# Client-side + + +http + + + + + +mix --output and --out-null + + +http://%HOSTIP:%HTTPPORT/want/%TESTNUMBER http://%HOSTIP:%HTTPPORT/want/%TESTNUMBER0002 --out-null -o - + + + +# Verify data after the test has been "shot" + + +GET /want/%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* + +GET /want/%TESTNUMBER0002 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* + + + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Response: 1 +Content-Type: text/html +Content-Length: 8 + +HTTP/1.1 200 OK +Date: Thu, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Response: 2 +Content-Type: text/html +Content-Length: 8 + +Hello2! + + +