File fetcher: Optimise HTTP header generation.

This commit is contained in:
Michael Drake 2019-11-10 14:35:07 +00:00
parent 8d652f1ff4
commit c14f01ea44

View File

@ -99,19 +99,21 @@ static bool fetch_file_send_header(struct fetch_file_context *ctx,
fetch_msg msg;
char header[64];
va_list ap;
int len;
va_start(ap, fmt);
vsnprintf(header, sizeof header, fmt, ap);
len = vsnprintf(header, sizeof header, fmt, ap);
va_end(ap);
if (len >= (int)sizeof(header) || len < 0) {
return false;
}
msg.type = FETCH_HEADER;
msg.data.header_or_data.buf = (const uint8_t *) header;
msg.data.header_or_data.len = strlen(header);
fetch_file_send_callback(&msg, ctx);
msg.data.header_or_data.len = len;
return ctx->aborted;
return fetch_file_send_callback(&msg, ctx);
}
/** callback to initialise the file fetcher. */