Artifactspublic-v0

curl

master
ply4 git calls25 ms289 KiB3 cachedprotocol v2
142 lines3.8 KiBRaw

NAME

CURLOPT_CUSTOMREQUEST - custom request method

SYNOPSIS

c
#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CUSTOMREQUEST, char *method);

DESCRIPTION

Pass a pointer to a null-terminated string as parameter.

When changing the request method by setting CURLOPT_CUSTOMREQUEST(3), you do not actually change how libcurl behaves or acts: you only change the actual string sent in the request.

libcurl passes on the verbatim string in its request without any filter or other safe guards. That includes white space and control characters.

The application does not have to keep the string around after setting this option.

Using this option multiple times makes the last set string override the previous ones. Restore to the internal default by setting this to NULL.

This option can be used to specify the request:

HTTP

Instead of GET or HEAD when performing HTTP based requests. This is particularly useful, for example, for performing an HTTP DELETE request.

For example:

When you tell libcurl to do a HEAD request, but then specify a GET though a custom request libcurl still acts as if it sent a HEAD. To switch to a proper HEAD use CURLOPT_NOBODY(3), to switch to a proper POST use CURLOPT_POST(3) or CURLOPT_POSTFIELDS(3) and to switch to a proper GET use CURLOPT_HTTPGET(3).

Many people have wrongly used this option to replace the entire request with their own, including multiple headers and POST contents. While that might work in many cases, it might cause libcurl to send invalid requests and it could possibly confuse the remote server badly. Use CURLOPT_POST(3) and CURLOPT_POSTFIELDS(3) to set POST data. Use CURLOPT_HTTPHEADER(3) to replace or extend the set of headers sent by libcurl. Use CURLOPT_HTTP_VERSION(3) to change the HTTP version.

When this option is used together with CURLOPT_FOLLOWLOCATION(3), the custom set method overrides the method libcurl could otherwise change to for the subsequent requests. You can fine-tune that decision by using the CURLFOLLOW_OBEYCODE bit to CURLOPT_FOLLOWLOCATION(3) to make redirects adhere to the redirect response code as the protocol instructs.

FTP

Instead of LIST and NLST when performing FTP directory listings.

IMAP

Instead of LIST when issuing IMAP based requests.

POP3

Instead of LIST and RETR when issuing POP3 based requests.

For example:

When you tell libcurl to use a custom request it behaves like a LIST or RETR command was sent where it expects data to be returned by the server. As such CURLOPT_NOBODY(3) should be used when specifying commands such as DELE and NOOP for example.

SMTP

Instead of a HELP or VRFY when issuing SMTP based requests.

For example:

Normally a multi line response is returned which can be used, in conjunction with CURLOPT_MAIL_RCPT(3), to specify an EXPN request. If the CURLOPT_NOBODY(3) option is specified then the request can be used to issue NOOP and RSET commands.

DEFAULT

NULL

%PROTOCOLS%

EXAMPLE

c
int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");

    /* DELETE the given path */
    curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");

    result = curl_easy_perform(curl);

    curl_easy_cleanup(curl);
  }
}

%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_CUSTOMREQUEST
5Section: 3
6Source: libcurl
7See-also:
8 - CURLINFO_EFFECTIVE_METHOD (3)
9 - CURLOPT_HTTPHEADER (3)
10 - CURLOPT_NOBODY (3)
11 - CURLOPT_REQUEST_TARGET (3)
12Protocol:
13 - HTTP
14 - FTP
15 - IMAP
16 - POP3
17 - SMTP
18Added-in: 7.1
19---
21# NAME
23CURLOPT_CUSTOMREQUEST - custom request method
25# SYNOPSIS
27~~~c
28#include <curl/curl.h>
30CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CUSTOMREQUEST, char *method);
31~~~
33# DESCRIPTION
35Pass a pointer to a null-terminated string as parameter.
37When changing the request *method* by setting CURLOPT_CUSTOMREQUEST(3), you do
38not actually change how libcurl behaves or acts: you only change the actual
39string sent in the request.
41libcurl passes on the verbatim string in its request without any filter or
42other safe guards. That includes white space and control characters.
44The application does not have to keep the string around after setting this
45option.
47Using this option multiple times makes the last set string override the
48previous ones. Restore to the internal default by setting this to NULL.
50This option can be used to specify the request:
52## HTTP
54Instead of GET or HEAD when performing HTTP based requests. This is
55particularly useful, for example, for performing an HTTP DELETE request.
57For example:
59When you tell libcurl to do a HEAD request, but then specify a GET though a
60custom request libcurl still acts as if it sent a HEAD. To switch to a proper
61HEAD use CURLOPT_NOBODY(3), to switch to a proper POST use
62CURLOPT_POST(3) or CURLOPT_POSTFIELDS(3) and to switch to a proper
63GET use CURLOPT_HTTPGET(3).
65Many people have wrongly used this option to replace the entire request with
66their own, including multiple headers and POST contents. While that might work
67in many cases, it might cause libcurl to send invalid requests and it could
68possibly confuse the remote server badly. Use CURLOPT_POST(3) and
69CURLOPT_POSTFIELDS(3) to set POST data. Use CURLOPT_HTTPHEADER(3) to replace
70or extend the set of headers sent by libcurl. Use CURLOPT_HTTP_VERSION(3) to
71change the HTTP version.
73When this option is used together with CURLOPT_FOLLOWLOCATION(3), the custom
74set method overrides the method libcurl could otherwise change to for the
75subsequent requests. You can fine-tune that decision by using the
76CURLFOLLOW_OBEYCODE bit to CURLOPT_FOLLOWLOCATION(3) to make redirects adhere
77to the redirect response code as the protocol instructs.
79## FTP
81Instead of LIST and NLST when performing FTP directory listings.
83## IMAP
85Instead of LIST when issuing IMAP based requests.
87## POP3
89Instead of LIST and RETR when issuing POP3 based requests.
91For example:
93When you tell libcurl to use a custom request it behaves like a LIST or RETR
94command was sent where it expects data to be returned by the server. As such
95CURLOPT_NOBODY(3) should be used when specifying commands such as
96**DELE** and **NOOP** for example.
98## SMTP
100Instead of a **HELP** or **VRFY** when issuing SMTP based requests.
102For example:
104Normally a multi line response is returned which can be used, in conjunction
105with CURLOPT_MAIL_RCPT(3), to specify an EXPN request. If the
106CURLOPT_NOBODY(3) option is specified then the request can be used to
107issue **NOOP** and **RSET** commands.
109# DEFAULT
111NULL
113# %PROTOCOLS%
115# EXAMPLE
117~~~c
118int main(void)
120 CURL *curl = curl_easy_init();
121 if(curl) {
122 CURLcode result;
123 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
125 /* DELETE the given path */
126 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
128 result = curl_easy_perform(curl);
130 curl_easy_cleanup(curl);
131 }
133~~~
135# %AVAILABILITY%
137# RETURN VALUE
139curl_easy_setopt(3) returns a CURLcode indicating success or error.
141CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
142libcurl-errors(3).
Diagnostics4 git calls · 25 ms
CallStatusSizeTime025 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
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=19
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.9 KiB · hit19 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1900
git.response.cache=HIT
git.response.duration_ms=19
git.fetch.wants=9928eef9d64ad000d1343d30515a37d0573b1e22
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=1900
git.pkt.payload.max=1879
git.sideband.band1.bytes=1878
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
a5e3557e1a12994c
Request
109d52a3…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format