curl_easy_pause.3 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH curl_easy_pause 3 "17 Dec 2007" "libcurl" "libcurl"
  25. .SH NAME
  26. curl_easy_pause - pause and unpause a connection
  27. .SH SYNOPSIS
  28. .nf
  29. .B #include <curl/curl.h>
  30. .BI "CURLcode curl_easy_pause(CURL *"handle ", int "bitmask ");"
  31. .fi
  32. .SH DESCRIPTION
  33. Using this function, you can explicitly mark a running connection to get
  34. paused, and you can unpause a connection that was previously paused.
  35. A connection can be paused by using this function or by letting the read or
  36. the write callbacks return the proper magic return code
  37. (\fICURL_READFUNC_PAUSE\fP and \fICURL_WRITEFUNC_PAUSE\fP). A write callback
  38. that returns pause signals to the library that it could not take care of any
  39. data at all, and that data will then be delivered again to the callback when
  40. the transfer is unpaused.
  41. While it may feel tempting, take care and notice that you cannot call this
  42. function from another thread. To unpause, you may for example call it from the
  43. progress callback (\fICURLOPT_PROGRESSFUNCTION(3)\fP).
  44. When this function is called to unpause receiving, the write callback might
  45. get called before this function returns to deliver cached content. When
  46. libcurl delivers such cached data to the write callback, it will be delivered
  47. as fast as possible, which may overstep the boundary set in
  48. \fICURLOPT_MAX_RECV_SPEED_LARGE(3)\fP etc.
  49. The \fBhandle\fP argument identifies the transfer you want to pause or
  50. unpause.
  51. A paused transfer is excluded from low speed cancels via the
  52. \fICURLOPT_LOW_SPEED_LIMIT(3)\fP option and unpausing a transfer will reset
  53. the time period required for the low speed limit to be met.
  54. The \fBbitmask\fP argument is a set of bits that sets the new state of the
  55. connection. The following bits can be used:
  56. .IP CURLPAUSE_RECV
  57. Pause receiving data. There will be no data received on this connection until
  58. this function is called again without this bit set. Thus, the write callback
  59. (\fICURLOPT_WRITEFUNCTION(3)\fP) will not be called.
  60. .IP CURLPAUSE_SEND
  61. Pause sending data. There will be no data sent on this connection until this
  62. function is called again without this bit set. Thus, the read callback
  63. (\fICURLOPT_READFUNCTION(3)\fP) will not be called.
  64. .IP CURLPAUSE_ALL
  65. Convenience define that pauses both directions.
  66. .IP CURLPAUSE_CONT
  67. Convenience define that unpauses both directions.
  68. .SH LIMITATIONS
  69. The pausing of transfers does not work with protocols that work without
  70. network connectivity, like FILE://. Trying to pause such a transfer, in any
  71. direction, will cause problems in the worst case or an error in the best case.
  72. .SH MULTIPLEXED
  73. When a connection is used multiplexed, like for HTTP/2, and one of the
  74. transfers over the connection is paused and the others continue flowing,
  75. libcurl might end up buffering contents for the paused transfer. It has to do
  76. this because it needs to drain the socket for the other transfers and the
  77. already announced window size for the paused transfer will allow the server to
  78. continue sending data up to that window size amount. By default, libcurl
  79. announces a 32 megabyte window size, which thus can make libcurl end up
  80. buffering 32 megabyte of data for a paused stream.
  81. When such a paused stream is unpaused again, any buffered data will be
  82. delivered first.
  83. .SH EXAMPLE
  84. .nf
  85. /* pause a transfer in both directions */
  86. curl_easy_pause(curl, CURL_READFUNC_PAUSE | CURL_WRITEFUNC_PAUSE);
  87. .fi
  88. .SH "MEMORY USE"
  89. When pausing a read by returning the magic return code from a write callback,
  90. the read data is already in libcurl's internal buffers so it will have to keep
  91. it in an allocated buffer until the receiving is again unpaused using this
  92. function.
  93. If the downloaded data is compressed and is asked to get uncompressed
  94. automatically on download, libcurl will continue to uncompress the entire
  95. downloaded chunk and it will cache the data uncompressed. This has the side-
  96. effect that if you download something that is compressed a lot, it can result
  97. in a large data amount needing to be allocated to save the data during the
  98. pause. This said, you should probably consider not using paused receiving if
  99. you allow libcurl to uncompress data automatically.
  100. .SH AVAILABILITY
  101. Added in 7.18.0.
  102. .SH RETURN VALUE
  103. CURLE_OK (zero) means that the option was set properly, and a non-zero return
  104. code means something wrong occurred after the new state was set. See the
  105. \fIlibcurl-errors(3)\fP man page for the full list with descriptions.
  106. .SH "SEE ALSO"
  107. .BR curl_easy_cleanup "(3), " curl_easy_reset "(3)"