mirror of
https://github.com/curl/curl.git
synced 2026-06-07 06:24:15 +03:00
Make --out-null work per url as --output
Add test755 to check that --out-null only applies to a singel url
This commit is contained in:
parent
3e49d3f154
commit
63b840dea3
8 changed files with 94 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 \
|
||||
\
|
||||
|
|
|
|||
80
tests/data/test756
Normal file
80
tests/data/test756
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
HTTP
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
# Server-side
|
||||
<reply>
|
||||
<data nocheck="yes">
|
||||
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!
|
||||
</data>
|
||||
<data2>
|
||||
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!
|
||||
</data2>
|
||||
</reply>
|
||||
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
http
|
||||
</server>
|
||||
<features>
|
||||
</features>
|
||||
|
||||
<name>
|
||||
mix --output and --out-null
|
||||
</name>
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/want/%TESTNUMBER http://%HOSTIP:%HTTPPORT/want/%TESTNUMBER0002 --out-null -o -
|
||||
</command>
|
||||
</client>
|
||||
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<protocol>
|
||||
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: */*
|
||||
|
||||
</protocol>
|
||||
<stdout>
|
||||
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!
|
||||
</stdout>
|
||||
</verify>
|
||||
</testcase>
|
||||
Loading…
Add table
Add a link
Reference in a new issue