}
}
-/* create the next (singular) transfer */
-static CURLcode single_transfer(struct OperationConfig *config,
- CURLSH *share, bool *added, bool *skipped)
+static void setup_header_cb(struct OperationConfig *config,
+ struct HdrCbData *hdrcbdata,
+ struct getout *u,
+ struct OutStruct *outs,
+ struct OutStruct *heads,
+ struct OutStruct *etag)
{
- CURLcode result = CURLE_OK;
- bool orig_noprogress = global->noprogress;
- bool orig_isatty = global->isatty;
- struct State *state = &global->state;
- char *httpgetfields = state->httpgetfields;
-
- *skipped = *added = FALSE; /* not yet */
-
- if(config->postfields) {
- if(config->use_httpget) {
- if(!httpgetfields) {
- /* Use the postfields data for an HTTP get */
- httpgetfields = state->httpgetfields = config->postfields;
- config->postfields = NULL;
- if(SetHTTPrequest((config->no_body ? TOOL_HTTPREQ_HEAD :
- TOOL_HTTPREQ_GET), &config->httpreq))
- return CURLE_FAILED_INIT;
- }
- }
- else if(SetHTTPrequest(TOOL_HTTPREQ_SIMPLEPOST, &config->httpreq))
- return CURLE_FAILED_INIT;
- }
-
- result = set_cert_types(config);
- if(result)
- return result;
-
- if(!state->urlnode) {
- /* first time caller, setup things */
- state->urlnode = config->url_list;
- state->upnum = 1;
- }
+ hdrcbdata->honor_cd_filename = (config->content_disposition && u->useremote);
+ hdrcbdata->outs = outs;
+ hdrcbdata->heads = heads;
+ hdrcbdata->etag_save = etag;
+ hdrcbdata->config = config;
+}
+/* create a transfer */
+static CURLcode create_single(struct OperationConfig *config,
+ CURLSH *share, struct State *state,
+ bool *added, bool *skipped)
+{
+ const bool orig_isatty = global->isatty;
+ const bool orig_noprogress = global->noprogress;
+ CURLcode result = CURLE_OK;
while(state->urlnode) {
struct per_transfer *per = NULL;
struct OutStruct *outs;
struct OutStruct *heads;
- struct HdrCbData *hdrcbdata = NULL;
struct OutStruct etag_first;
CURL *curl;
struct getout *u = state->urlnode;
if(result)
return result;
}
- hdrcbdata = &per->hdrcbdata;
-
outs = &per->outs;
per->outfile = NULL;
global->isatty = orig_isatty;
}
- if(httpgetfields || config->query) {
- result = append2query(config, per,
- httpgetfields ? httpgetfields : config->query);
+ if(state->httpgetfields) {
+ result = append2query(config, per, state->httpgetfields);
if(result)
return result;
}
/* explicitly passed to stdout means okaying binary gunk */
config->terminal_binary_ok = (per->outfile && !strcmp(per->outfile, "-"));
- hdrcbdata->honor_cd_filename =
- (config->content_disposition && u->useremote);
- hdrcbdata->outs = outs;
- hdrcbdata->heads = heads;
- hdrcbdata->etag_save = &etag_first;
- hdrcbdata->config = config;
+ setup_header_cb(config, &per->hdrcbdata, u, outs, heads, &etag_first);
result = config2setopts(config, per, curl, share);
if(result)
per->retry_sleep = per->retry_sleep_default; /* ms */
per->retrystart = curlx_now();
- state->urlidx++;
/* Here's looping around each globbed URL */
- if(state->urlidx >= state->urlnum) {
+ if(++state->urlidx >= state->urlnum) {
state->urlidx = state->urlnum = 0;
glob_cleanup(&state->urlglob);
state->upidx++;
return result;
}
+/* create the next (singular) transfer */
+static CURLcode single_transfer(struct OperationConfig *config,
+ CURLSH *share, bool *added, bool *skipped)
+{
+ CURLcode result = CURLE_OK;
+ struct State *state = &global->state;
+ char *httpgetfields = state->httpgetfields;
+
+ *skipped = *added = FALSE; /* not yet */
+
+ if(config->postfields) {
+ if(config->use_httpget) {
+ if(!httpgetfields) {
+ /* Use the postfields data for an HTTP get */
+ httpgetfields = state->httpgetfields = config->postfields;
+ config->postfields = NULL;
+ if(SetHTTPrequest((config->no_body ? TOOL_HTTPREQ_HEAD :
+ TOOL_HTTPREQ_GET), &config->httpreq))
+ return CURLE_FAILED_INIT;
+ }
+ }
+ else if(SetHTTPrequest(TOOL_HTTPREQ_SIMPLEPOST, &config->httpreq))
+ return CURLE_FAILED_INIT;
+ }
+ if(!httpgetfields)
+ state->httpgetfields = config->query;
+
+ result = set_cert_types(config);
+ if(result)
+ return result;
+
+ if(!state->urlnode) {
+ /* first time caller, setup things */
+ state->urlnode = config->url_list;
+ state->upnum = 1;
+ }
+
+ return create_single(config, share, state, added, skipped);
+}
+
static long all_added; /* number of easy handles currently added */
/*