CURLOPT_STREAM_WEIGHT.3 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. .\" generated by cd2nroff 0.1 from CURLOPT_STREAM_WEIGHT.md
  2. .TH CURLOPT_STREAM_WEIGHT 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_STREAM_WEIGHT \- numerical stream weight
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_STREAM_WEIGHT, long weight);
  9. .fi
  10. .SH DESCRIPTION
  11. Set the long \fIweight\fP to a number between 1 and 256.
  12. When using HTTP/2, this option sets the individual weight for this particular
  13. stream used by the easy \fIhandle\fP. Setting and using weights only makes
  14. sense and is only usable when doing multiple streams over the same
  15. connections, which thus implies that you use \fICURLMOPT_PIPELINING(3)\fP.
  16. This option can be set during transfer and causes the updated weight info get
  17. sent to the server the next time an HTTP/2 frame is sent to the server.
  18. See section 5.3 of RFC 7540 for protocol details.
  19. Streams with the same parent should be allocated resources proportionally
  20. based on their weight. If you have two streams going, stream A with weight 16
  21. and stream B with weight 32, stream B gets two thirds (32/48) of the available
  22. bandwidth (assuming the server can send off the data equally for both
  23. streams).
  24. .SH DEFAULT
  25. 16
  26. .SH PROTOCOLS
  27. This functionality affects http only
  28. .SH EXAMPLE
  29. .nf
  30. int main(void)
  31. {
  32. CURL *curl = curl_easy_init();
  33. CURL *curl2 = curl_easy_init(); /* a second handle */
  34. if(curl) {
  35. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/one");
  36. curl_easy_setopt(curl, CURLOPT_STREAM_WEIGHT, 10L);
  37. /* the second has twice the weight */
  38. curl_easy_setopt(curl2, CURLOPT_URL, "https://example.com/two");
  39. curl_easy_setopt(curl2, CURLOPT_STREAM_WEIGHT, 20L);
  40. /* then add both to a multi handle and transfer them! */
  41. }
  42. }
  43. .fi
  44. .SH AVAILABILITY
  45. Added in curl 7.46.0
  46. .SH RETURN VALUE
  47. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  48. .SH SEE ALSO
  49. .BR CURLMOPT_PIPELINING (3),
  50. .BR CURLOPT_PIPEWAIT (3),
  51. .BR CURLOPT_STREAM_DEPENDS (3),
  52. .BR CURLOPT_STREAM_DEPENDS_E (3)