Artifactspublic-v0

curl

master
ply4 git calls66 ms288 KiB3 cachedprotocol v2
110 lines3.4 KiBRaw

--variable

Set a variable with name=content or name@file (where file can be stdin if set to a single dash (-)). The name is a case sensitive identifier that must consist of no other letters than a-z, A-Z, 0-9 or underscore. The specified content is then associated with this identifier.

Setting the same variable name again overwrites the old contents with the new.

The contents of a variable can be referenced in a later command line option when that option name is prefixed with --expand-, and the name is used as {{name}}.

--variable can import environment variables into the name space. Opt to either require the environment variable to be set or provide a default value for the variable in case it is not already set.

--variable %name imports the variable called name but exits with an error if that environment variable is not already set. To provide a default value if the environment variable is not set, use --variable %name=content or --variable %name@content. Note that on some systems - but not all - environment variables are case insensitive.

Added in curl 8.12.0: you can get a byte range from the source by appending [start-end] to the variable name, where start and end are byte offsets to include from the contents. For example, asking for offset "2-10" means offset two to offset ten, inclusive, resulting in 9 bytes in total. 2-2 means a single byte at offset 2. Not providing a second number implies to the end of data. The start offset cannot be larger than the end offset. Asking for a range that is outside of the file size makes the variable contents empty. For example, getting the first one hundred bytes from a given file:

curl --variable "fraction[0-99]@filename"

Given a byte range that has no data results in an empty string. Asking for a range that is larger than the content makes curl use the piece of the data that exists.

To assign a variable using contents from another variable, use --expand-variable. Like for example assigning a new variable using contents from two other:

curl --expand-variable "user={{firstname}} {{lastname}}"

When expanding variables, curl supports a set of functions that can make the variable contents more convenient to use. You apply a function to a variable expansion by adding a colon and then list the desired functions in a comma-separated list that is evaluated in a left-to-right order. Variable content holding null bytes that are not encoded when expanded causes an error.

Available functions:

trim

removes all leading and trailing white space.

Example:

curl --expand-url https://example.com/{{var:trim}}

json

outputs the content using JSON string quoting rules.

Example:

curl --expand-data {{data:json}} https://example.com

url

shows the content URL (percent) encoded.

Example:

curl --expand-url https://example.com/{{path:url}}

b64

expands the variable base64 encoded

Example:

curl --expand-url https://example.com/{{var:b64}}

64dec

decodes a base64 encoded character sequence. If the sequence is not possible to decode, it instead outputs [64dec-fail]

Example:

curl --expand-url https://example.com/{{var:64dec}}

(Added in 8.13.0)

1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Long: variable
5Arg: <[%]name=text/@file>
6Help: Set variable
7Category: curl
8Added: 8.3.0
9Multi: append
10See-also:
11 - config
12Example:
13 - --variable name=smith --expand-url "$URL/{{name}}"
14---
16# `--variable`
18Set a variable with `name=content` or `name@file` (where `file` can be stdin
19if set to a single dash (`-`)). The name is a case sensitive identifier that
20must consist of no other letters than a-z, A-Z, 0-9 or underscore. The
21specified content is then associated with this identifier.
23Setting the same variable name again overwrites the old contents with the new.
25The contents of a variable can be referenced in a later command line option
26when that option name is prefixed with `--expand-`, and the name is used as
27`{{name}}`.
29--variable can import environment variables into the name space. Opt to either
30require the environment variable to be set or provide a default value for the
31variable in case it is not already set.
33--variable %name imports the variable called `name` but exits with an error if
34that environment variable is not already set. To provide a default value if
35the environment variable is not set, use --variable %name=content or
36--variable %name@content. Note that on some systems - but not all -
37environment variables are case insensitive.
39Added in curl 8.12.0: you can get a byte range from the source by appending
40`[start-end]` to the variable name, where *start* and *end* are byte offsets
41to include from the contents. For example, asking for offset "2-10" means
42offset two to offset ten, inclusive, resulting in 9 bytes in total. `2-2`
43means a single byte at offset 2. Not providing a second number implies to the
44end of data. The start offset cannot be larger than the end offset. Asking for
45a range that is outside of the file size makes the variable contents empty.
46For example, getting the first one hundred bytes from a given file:
48 curl --variable "fraction[0-99]@filename"
50Given a byte range that has no data results in an empty string. Asking for a
51range that is larger than the content makes curl use the piece of the data
52that exists.
54To assign a variable using contents from another variable, use
55--expand-variable. Like for example assigning a new variable using contents
56from two other:
58 curl --expand-variable "user={{firstname}} {{lastname}}"
60When expanding variables, curl supports a set of functions that can make the
61variable contents more convenient to use. You apply a function to a variable
62expansion by adding a colon and then list the desired functions in a
63comma-separated list that is evaluated in a left-to-right order. Variable
64content holding null bytes that are not encoded when expanded causes an
65error.
67Available functions:
69## `trim`
71removes all leading and trailing white space.
73Example:
75 curl --expand-url https://example.com/{{var:trim}}
77## `json`
79outputs the content using JSON string quoting rules.
81Example:
83 curl --expand-data {{data:json}} https://example.com
85## `url`
87shows the content URL (percent) encoded.
89Example:
91 curl --expand-url https://example.com/{{path:url}}
93## `b64`
95expands the variable base64 encoded
97Example:
99 curl --expand-url https://example.com/{{var:b64}}
101## `64dec`
103decodes a base64 encoded character sequence. If the sequence is not possible
104to decode, it instead outputs `[64dec-fail]`
106Example:
108 curl --expand-url https://example.com/{{var:64dec}}
110(Added in 8.13.0)
Diagnostics4 git calls · 66 ms
CallStatusSizeTime066 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=3
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 KiB · hit60 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=60
git.response.bytes=1652
git.response.cache=HIT
git.response.duration_ms=60
git.fetch.wants=95affb263a2b244f1d4903fda4a3bb7313220615
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=1652
git.pkt.payload.max=1631
git.sideband.band1.bytes=1630
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
a5e2a27d2f5b1293
Request
0a3c953e…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format