Artifactspublic-v0

curl

master
ply4 git calls234 ms289 KiB2 cachedprotocol v2
134 lines3.6 KiBRaw

NAME

CURLOPT_PROGRESSFUNCTION - progress meter callback

SYNOPSIS

c
#include <curl/curl.h>

int progress_callback(void *clientp,
                      double dltotal,
                      double dlnow,
                      double ultotal,
                      double ulnow);

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSFUNCTION,
                          progress_callback);

DESCRIPTION

Pass a pointer to your callback function, which should match the prototype shown above.

This option is deprecated and we encourage users to use the newer CURLOPT_XFERINFOFUNCTION(3) instead, if you can.

This function gets called by libcurl instead of its internal equivalent with a frequent interval. While data is being transferred it is invoked frequently, and during slow periods like when nothing is being transferred it can slow down to about one call per second.

clientp is the pointer set with CURLOPT_PROGRESSDATA(3), it is not used by libcurl but is only passed along from the application to the callback.

The callback gets told how much data libcurl is about to transfer and has transferred, in number of bytes. dltotal is the total number of bytes libcurl expects to download in this transfer. dlnow is the number of bytes downloaded so far. ultotal is the total number of bytes libcurl expects to upload in this transfer. ulnow is the number of bytes uploaded so far.

Unknown/unused argument values passed to the callback are be set to zero (like if you only download data, the upload size remains 0). Many times the callback is called one or more times first, before it knows the data sizes so a program must be made to handle that.

Return zero from the callback if everything is fine.

If your callback function returns CURL_PROGRESSFUNC_CONTINUE it causes libcurl to continue executing the default progress function.

Return 1 from this callback to make libcurl abort the transfer and return CURLE_ABORTED_BY_CALLBACK.

If you transfer data with the multi interface, this function is not called during periods of idleness unless you call the appropriate libcurl function that performs transfers.

CURLOPT_NOPROGRESS(3) must be set to 0 to make this function actually get called.

DEFAULT

NULL. libcurl has an internal progress meter. That is rarely wanted by users.

%PROTOCOLS%

EXAMPLE

c
struct progress {
  char *private_data;
  size_t size;
};

static int progress_callback(void *clientp,
                             double dltotal,
                             double dlnow,
                             double ultotal,
                             double ulnow)
{
  struct progress *memory = clientp;
  printf("private: %p\n", (void *)memory->private_data);

  /* use the values */

  return 0; /* all is good */
}

int main(void)
{
  struct progress data;

  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    /* pass struct to callback */
    curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data);
    curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);

    result = curl_easy_perform(curl);
    curl_easy_cleanup(curl);
  }
}

DEPRECATED

Deprecated since 7.32.0.

%AVAILABILITY%

RETURN VALUE

curl_easy_setopt(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3).

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_PROGRESSFUNCTION
5Section: 3
6Source: libcurl
7See-also:
8 - CURLOPT_NOPROGRESS (3)
9 - CURLOPT_VERBOSE (3)
10 - CURLOPT_XFERINFOFUNCTION (3)
11Protocol:
12 - All
13Added-in: 7.1
14---
16# NAME
18CURLOPT_PROGRESSFUNCTION - progress meter callback
20# SYNOPSIS
22~~~c
23#include <curl/curl.h>
25int progress_callback(void *clientp,
26 double dltotal,
27 double dlnow,
28 double ultotal,
29 double ulnow);
31CURLcode curl_easy_setopt(CURL *handle, CURLOPT_PROGRESSFUNCTION,
32 progress_callback);
33~~~
35# DESCRIPTION
37Pass a pointer to your callback function, which should match the prototype
38shown above.
40This option is deprecated and we encourage users to use the
41newer CURLOPT_XFERINFOFUNCTION(3) instead, if you can.
43This function gets called by libcurl instead of its internal equivalent with a
44frequent interval. While data is being transferred it is invoked frequently,
45and during slow periods like when nothing is being transferred it can slow
46down to about one call per second.
48*clientp* is the pointer set with CURLOPT_PROGRESSDATA(3), it is not
49used by libcurl but is only passed along from the application to the callback.
51The callback gets told how much data libcurl is about to transfer and has
52transferred, in number of bytes. *dltotal* is the total number of bytes
53libcurl expects to download in this transfer. *dlnow* is the number of
54bytes downloaded so far. *ultotal* is the total number of bytes libcurl
55expects to upload in this transfer. *ulnow* is the number of bytes
56uploaded so far.
58Unknown/unused argument values passed to the callback are be set to zero (like
59if you only download data, the upload size remains 0). Many times the callback
60is called one or more times first, before it knows the data sizes so a program
61must be made to handle that.
63Return zero from the callback if everything is fine.
65If your callback function returns CURL_PROGRESSFUNC_CONTINUE it causes libcurl
66to continue executing the default progress function.
68Return 1 from this callback to make libcurl abort the transfer and return
69*CURLE_ABORTED_BY_CALLBACK*.
71If you transfer data with the multi interface, this function is not called
72during periods of idleness unless you call the appropriate libcurl function
73that performs transfers.
75CURLOPT_NOPROGRESS(3) must be set to 0 to make this function actually
76get called.
78# DEFAULT
80NULL. libcurl has an internal progress meter. That is rarely wanted by users.
82# %PROTOCOLS%
84# EXAMPLE
86~~~c
87struct progress {
88 char *private_data;
89 size_t size;
90};
92static int progress_callback(void *clientp,
93 double dltotal,
94 double dlnow,
95 double ultotal,
96 double ulnow)
98 struct progress *memory = clientp;
99 printf("private: %p\n", (void *)memory->private_data);
101 /* use the values */
103 return 0; /* all is good */
106int main(void)
108 struct progress data;
110 CURL *curl = curl_easy_init();
111 if(curl) {
112 CURLcode result;
113 /* pass struct to callback */
114 curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data);
115 curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
117 result = curl_easy_perform(curl);
118 curl_easy_cleanup(curl);
119 }
121~~~
123# DEPRECATED
125Deprecated since 7.32.0.
127# %AVAILABILITY%
129# RETURN VALUE
131curl_easy_setopt(3) returns a CURLcode indicating success or error.
133CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
134libcurl-errors(3).
Diagnostics4 git calls · 234 ms
CallStatusSizeTime0234 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2001.6 KiB228 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=228
git.response.bytes=1656
git.response.cache=MISS
git.response.duration_ms=228
git.fetch.wants=41fb91ae9ad87cc29d2c06a81d7e996d00d9f642
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1656
git.pkt.payload.max=1635
git.sideband.band1.bytes=1634
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e312b04afb3e6e
Request
4a8b5059…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format