Artifactspublic-v0

curl

master
ply4 git calls136 ms289 KiB2 cachedprotocol v2
149 lines4.7 KiBRaw

NAME

CURLOPT_URL - URL for this transfer

SYNOPSIS

c
#include <curl/curl.h>

CURLcode curl_easy_setopt(CURL *handle, CURLOPT_URL, char *URL);

DESCRIPTION

Pass in a pointer to the URL to work with. The parameter should be a char * to a null-terminated string which must be URL-encoded in the following format:

scheme://host:port/path

For a greater explanation of the format please see RFC 3986.

libcurl does not validate the syntax or use the URL until the transfer is started. Even if you set a crazy value here, curl_easy_setopt(3) might still return CURLE_OK.

If the given URL is missing a scheme name (such as http:// or ftp:// etc) then libcurl guesses based on the host. If the outermost subdomain name matches DICT, FTP, IMAP, LDAP, POP3 or SMTP then that protocol gets used, otherwise HTTP is used. Scheme guessing can be disabled by setting a default protocol, see CURLOPT_DEFAULT_PROTOCOL(3) for details.

Should the protocol, either as specified by the URL scheme or deduced by libcurl from the hostname, not be supported by libcurl then CURLE_UNSUPPORTED_PROTOCOL is returned from either the curl_easy_perform(3) or curl_multi_perform(3) functions when you call them. Use curl_version_info(3) for detailed information of which protocols are supported by the build of libcurl you are using.

CURLOPT_PROTOCOLS_STR(3) can be used to limit what protocols libcurl may use for this transfer, independent of what libcurl has been compiled to support. That may be useful if you accept the URL from an external source and want to limit the accessibility.

The CURLOPT_URL(3) string is ignored if CURLOPT_CURLU(3) is set.

Either CURLOPT_URL(3) or CURLOPT_CURLU(3) must be set before a transfer is started.

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. Set it to NULL to disable its use again. Note however that libcurl needs a URL set to be able to perform a transfer.

The parser used for handling the URL set with CURLOPT_URL(3) is the same that curl_url_set(3) uses.

ENCODING

The string pointed to in the CURLOPT_URL(3) argument is generally expected to be a sequence of characters using an ASCII compatible encoding.

If libcurl is built with IDN support, the server name part of the URL can use an "international name" by using the current encoding (according to locale) or UTF-8 (when WinIDN is used; or a Windows Unicode build using libidn2).

If libcurl is built without IDN support, the server name is used exactly as specified when passed to the name resolver functions.

DEFAULT

NULL. If this option is not set, no transfer can be performed.

SECURITY CONCERNS

Applications may at times find it convenient to allow users to specify URLs for various purposes and that string would then end up fed to this option.

Getting a URL from an external untrusted party brings several security concerns:

If you have an application that runs as or in a server application, getting an unfiltered URL can easily trick your application to access a local resource instead of a remote. Protecting yourself against localhost accesses is hard when accepting user provided URLs.

Such custom URLs can also access other ports than you planned as port numbers are part of the regular URL format. The combination of a local host and a custom port number can allow external users to play tricks with your local services.

Accepting external URLs may also use other protocols than http:// or other common ones. Restrict what accept with CURLOPT_PROTOCOLS_STR(3).

User provided URLs can also be made to point to sites that redirect further on (possibly to other protocols too). Consider your CURLOPT_FOLLOWLOCATION(3) and CURLOPT_REDIR_PROTOCOLS_STR(3) settings.

%PROTOCOLS%

EXAMPLE

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

    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).

Note that curl_easy_setopt(3) does not parse the given string so given a bad URL, it is not detected until curl_easy_perform(3) or similar is called.

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_URL
5Section: 3
6Source: libcurl
7See-also:
8 - CURLINFO_REDIRECT_URL (3)
9 - CURLOPT_CURLU (3)
10 - CURLOPT_FORBID_REUSE (3)
11 - CURLOPT_FRESH_CONNECT (3)
12 - CURLOPT_PATH_AS_IS (3)
13 - CURLOPT_PROTOCOLS_STR (3)
14 - curl_easy_perform (3)
15 - curl_url_get (3)
16 - curl_url_set (3)
17Protocol:
18 - All
19Added-in: 7.1
20---
22# NAME
24CURLOPT_URL - URL for this transfer
26# SYNOPSIS
28~~~c
29#include <curl/curl.h>
31CURLcode curl_easy_setopt(CURL *handle, CURLOPT_URL, char *URL);
32~~~
34# DESCRIPTION
36Pass in a pointer to the *URL* to work with. The parameter should be a char *
37to a null-terminated string which must be URL-encoded in the following format:
39scheme://host:port/path
41For a greater explanation of the format please see RFC 3986.
43libcurl does not validate the syntax or use the URL until the transfer is
44started. Even if you set a crazy value here, curl_easy_setopt(3) might still
45return *CURLE_OK*.
47If the given URL is missing a scheme name (such as `http://` or `ftp://` etc)
48then libcurl guesses based on the host. If the outermost subdomain name
49matches DICT, FTP, IMAP, LDAP, POP3 or SMTP then that protocol gets used,
50otherwise HTTP is used. Scheme guessing can be disabled by setting a default
51protocol, see CURLOPT_DEFAULT_PROTOCOL(3) for details.
53Should the protocol, either as specified by the URL scheme or deduced by
54libcurl from the hostname, not be supported by libcurl then
55*CURLE_UNSUPPORTED_PROTOCOL* is returned from either the curl_easy_perform(3)
56or curl_multi_perform(3) functions when you call them. Use
57curl_version_info(3) for detailed information of which protocols are supported
58by the build of libcurl you are using.
60CURLOPT_PROTOCOLS_STR(3) can be used to limit what protocols libcurl may use
61for this transfer, independent of what libcurl has been compiled to support.
62That may be useful if you accept the URL from an external source and want to
63limit the accessibility.
65The CURLOPT_URL(3) string is ignored if CURLOPT_CURLU(3) is set.
67Either CURLOPT_URL(3) or CURLOPT_CURLU(3) must be set before a transfer is
68started.
70The application does not have to keep the string around after setting this
71option.
73Using this option multiple times makes the last set string override the
74previous ones. Set it to NULL to disable its use again. Note however that
75libcurl needs a URL set to be able to perform a transfer.
77The parser used for handling the URL set with CURLOPT_URL(3) is the same that
78curl_url_set(3) uses.
80# ENCODING
82The string pointed to in the CURLOPT_URL(3) argument is generally expected to
83be a sequence of characters using an ASCII compatible encoding.
85If libcurl is built with IDN support, the server name part of the URL can use
86an "international name" by using the current encoding (according to locale) or
87UTF-8 (when WinIDN is used; or a Windows Unicode build using libidn2).
89If libcurl is built without IDN support, the server name is used exactly as
90specified when passed to the name resolver functions.
92# DEFAULT
94NULL. If this option is not set, no transfer can be performed.
96# SECURITY CONCERNS
98Applications may at times find it convenient to allow users to specify URLs
99for various purposes and that string would then end up fed to this option.
101Getting a URL from an external untrusted party brings several security
102concerns:
104If you have an application that runs as or in a server application, getting an
105unfiltered URL can easily trick your application to access a local resource
106instead of a remote. Protecting yourself against localhost accesses is hard
107when accepting user provided URLs.
109Such custom URLs can also access other ports than you planned as port numbers
110are part of the regular URL format. The combination of a local host and a
111custom port number can allow external users to play tricks with your local
112services.
114Accepting external URLs may also use other protocols than `http://` or other
115common ones. Restrict what accept with CURLOPT_PROTOCOLS_STR(3).
117User provided URLs can also be made to point to sites that redirect further on
118(possibly to other protocols too). Consider your
119CURLOPT_FOLLOWLOCATION(3) and CURLOPT_REDIR_PROTOCOLS_STR(3) settings.
121# %PROTOCOLS%
123# EXAMPLE
125~~~c
126int main(void)
128 CURL *curl = curl_easy_init();
129 if(curl) {
130 CURLcode result;
131 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
133 result = curl_easy_perform(curl);
134 curl_easy_cleanup(curl);
135 }
137~~~
139# %AVAILABILITY%
141# RETURN VALUE
143curl_easy_setopt(3) returns a CURLcode indicating success or error.
145CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
146libcurl-errors(3).
148Note that curl_easy_setopt(3) does not parse the given string so given a bad
149URL, it is not detected until curl_easy_perform(3) or similar is called.
Diagnostics4 git calls · 136 ms
CallStatusSizeTime0136 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
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 · hit2 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=2
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
fetch2002.3 KiB131 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=131
git.response.bytes=2392
git.response.cache=MISS
git.response.duration_ms=131
git.fetch.wants=1790ce3288e90559a6e9b3ff09b92e12539ee03d
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=2392
git.pkt.payload.max=2371
git.sideband.band1.bytes=2370
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
a5e31388ae5e3e6e
Request
4831dc7b…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format