1CURLOPT_STREAM_WEIGHT(3)   curl_easy_setopt options   CURLOPT_STREAM_WEIGHT(3)
2
3
4

NAME

6       CURLOPT_STREAM_WEIGHT - numerical stream weight
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STREAM_WEIGHT, long weight);
12

DESCRIPTION

14       Set the long weight to a number between 1 and 256.
15
16       When using HTTP/2, this option sets the individual weight for this par‐
17       ticular stream used by the easy handle. Setting and using weights  only
18       makes  sense  and  is  only usable when doing multiple streams over the
19       same connections, which thus implies  that  you  use  CURLMOPT_PIPELIN‐
20       ING(3).
21
22       This  option can be set during transfer and will then cause the updated
23       weight info get sent to the server the next time  an  HTTP/2  frame  is
24       sent to the server.
25
26       See    section    5.3    of    RFC    7540    for   protocol   details:
27       https://httpwg.github.io/specs/rfc7540.html#StreamPriority
28
29       Streams with the same parent should be allocated resources  proportion‐
30       ally  based on their weight. So if you have two streams going, stream A
31       with weight 16 and stream B with weight  32,  stream  B  will  get  two
32       thirds (32/48) of the available bandwidth (assuming the server can send
33       off the data equally for both streams).
34

DEFAULT

36       If nothing is set, the HTTP/2 protocol itself will use its own  default
37       which is 16.
38

PROTOCOLS

40       HTTP/2
41

EXAMPLE

43       CURL *curl = curl_easy_init();
44       CURL *curl2 = curl_easy_init(); /* a second handle */
45       if(curl) {
46         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one");
47         curl_easy_setopt(curl, CURLOPT_STREAM_WEIGHT, 10L);
48
49         /* the second has twice the weight */
50         curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two");
51         curl_easy_setopt(curl2, CURLOPT_STREAM_WEIGHT, 20L);
52
53         /* then add both to a multi handle and transfer them! */
54       }
55

AVAILABILITY

57       Added in 7.46.0
58

RETURN VALUE

60       Returns  CURLE_OK  if the option is supported, and CURLE_UNKNOWN_OPTION
61       if not.
62

SEE ALSO

64       CURLOPT_STREAM_DEPENDS(3),      CURLOPT_STREAM_DEPENDS_E(3),       CUR‐
65       LOPT_PIPEWAIT(3), CURLMOPT_PIPELINING(3),
66
67
68
69libcurl 7.85.0                   May 17, 2022         CURLOPT_STREAM_WEIGHT(3)
Impressum