Artifactspublic-v0

curl

master
ply4 git calls224 ms288 KiB2 cachedprotocol v2
109 lines2.5 KiBRaw

NAME

CURLOPT_IOCTLFUNCTION - callback for I/O operations

SYNOPSIS

c
#include <curl/curl.h>

typedef enum {
  CURLIOE_OK,            /* I/O operation successful */
  CURLIOE_UNKNOWNCMD,    /* command was unknown to callback */
  CURLIOE_FAILRESTART,   /* failed to restart the read */
  CURLIOE_LAST           /* never use */
} curlioerr;

typedef enum {
  CURLIOCMD_NOP,         /* no operation */
  CURLIOCMD_RESTARTREAD, /* restart the read stream from start */
  CURLIOCMD_LAST         /* never use */
} curliocmd;

curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp);

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLFUNCTION, ioctl_callback);

DESCRIPTION

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

This callback function gets called by libcurl when something special I/O-related needs to be done that the library cannot do by itself. For now, rewinding the read data stream is the only action it can request. The rewinding of the read data stream may be necessary when doing an HTTP PUT or POST with a multi-pass authentication method.

The callback must return CURLIOE_UNKNOWNCMD if the input cmd is not CURLIOCMD_RESTARTREAD.

The clientp argument to the callback is set with the CURLOPT_IOCTLDATA(3) option.

This option is deprecated. Do not use it. Use CURLOPT_SEEKFUNCTION(3) instead to provide seeking. If CURLOPT_SEEKFUNCTION(3) is set, this parameter is ignored when seeking.

DEFAULT

NULL

%PROTOCOLS%

EXAMPLE

c
#include <unistd.h> /* for lseek */

struct data {
  int fd; /* our file descriptor */
};

static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
{
  struct data *io = (struct data *)clientp;
  if(cmd == CURLIOCMD_RESTARTREAD) {
    lseek(io->fd, 0, SEEK_SET);
    return CURLIOE_OK;
  }
  return CURLIOE_UNKNOWNCMD;
}
int main(void)
{
  struct data ioctl_data;
  CURL *curl = curl_easy_init();
  if(curl) {
    curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
    curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data);
  }
}

DEPRECATED

Deprecated since 7.18.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_IOCTLFUNCTION
5Section: 3
6Source: libcurl
7Protocol:
8 - All
9See-also:
10 - CURLOPT_IOCTLDATA (3)
11 - CURLOPT_SEEKFUNCTION (3)
12Added-in: 7.12.3
13---
15# NAME
17CURLOPT_IOCTLFUNCTION - callback for I/O operations
19# SYNOPSIS
21~~~c
22#include <curl/curl.h>
24typedef enum {
25 CURLIOE_OK, /* I/O operation successful */
26 CURLIOE_UNKNOWNCMD, /* command was unknown to callback */
27 CURLIOE_FAILRESTART, /* failed to restart the read */
28 CURLIOE_LAST /* never use */
29} curlioerr;
31typedef enum {
32 CURLIOCMD_NOP, /* no operation */
33 CURLIOCMD_RESTARTREAD, /* restart the read stream from start */
34 CURLIOCMD_LAST /* never use */
35} curliocmd;
37curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp);
39CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IOCTLFUNCTION, ioctl_callback);
40~~~
42# DESCRIPTION
44Pass a pointer to your callback function, which should match the prototype
45shown above.
47This callback function gets called by libcurl when something special
48I/O-related needs to be done that the library cannot do by itself. For now,
49rewinding the read data stream is the only action it can request. The
50rewinding of the read data stream may be necessary when doing an HTTP PUT or
51POST with a multi-pass authentication method.
53The callback **must** return *CURLIOE_UNKNOWNCMD* if the input *cmd* is not
54*CURLIOCMD_RESTARTREAD*.
56The *clientp* argument to the callback is set with the CURLOPT_IOCTLDATA(3)
57option.
59**This option is deprecated**. Do not use it. Use CURLOPT_SEEKFUNCTION(3)
60instead to provide seeking. If CURLOPT_SEEKFUNCTION(3) is set, this parameter
61is ignored when seeking.
63# DEFAULT
65NULL
67# %PROTOCOLS%
69# EXAMPLE
71~~~c
72#include <unistd.h> /* for lseek */
74struct data {
75 int fd; /* our file descriptor */
76};
78static curlioerr ioctl_callback(CURL *handle, int cmd, void *clientp)
80 struct data *io = (struct data *)clientp;
81 if(cmd == CURLIOCMD_RESTARTREAD) {
82 lseek(io->fd, 0, SEEK_SET);
83 return CURLIOE_OK;
84 }
85 return CURLIOE_UNKNOWNCMD;
87int main(void)
89 struct data ioctl_data;
90 CURL *curl = curl_easy_init();
91 if(curl) {
92 curl_easy_setopt(curl, CURLOPT_IOCTLFUNCTION, ioctl_callback);
93 curl_easy_setopt(curl, CURLOPT_IOCTLDATA, &ioctl_data);
94 }
96~~~
98# DEPRECATED
100Deprecated since 7.18.0.
102# %AVAILABILITY%
104# RETURN VALUE
106curl_easy_setopt(3) returns a CURLcode indicating success or error.
108CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
109libcurl-errors(3).
Diagnostics4 git calls · 224 ms
CallStatusSizeTime0224 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
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 · hit8 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=214
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=8
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.3 KiB214 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1306
git.response.cache=MISS
git.response.duration_ms=214
git.fetch.wants=939161bee0ce20d0ed1b7a1d8e05ae4d263c9d99
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=1306
git.pkt.payload.max=1285
git.sideband.band1.bytes=1284
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
a5e328415bce4628
Request
a7001288…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format