2
0

curl_easy_nextheader.3 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2022, 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. .\" **************************************************************************
  22. .TH curl_easy_nextheader 3 "13 March 2022" "libcurl 7.83.0" "libcurl Manual"
  23. .SH NAME
  24. curl_easy_nextheader - get the next HTTP header
  25. .SH SYNOPSIS
  26. .nf
  27. #include <curl/curl.h>
  28. struct curl_header *curl_easy_nextheader(CURL *easy,
  29. unsigned int origin,
  30. int request,
  31. struct curl_header *prev);
  32. .fi
  33. .SH DESCRIPTION
  34. EXPERIMENTAL feature!
  35. This function lets an application iterate over all previously received HTTP
  36. headers.
  37. The \fIorigin\fP argument is for specifying which headers to receive, as a
  38. single HTTP transfer might provide headers from several different places and
  39. they may then have different importance to the user and headers using the same
  40. name might be used. The \fIorigin\fP is a bitmask for what header sources you
  41. want. See the \fIcurl_easy_header(3)\fP man page for the origin descriptions.
  42. The \fIrequest\fP argument tells libcurl from which request you want headers
  43. from. A single transfer might consist of a series of HTTP requests and this
  44. argument lets you specify which particular individual request you want the
  45. headers from. 0 being the first request and then the number increases for
  46. further redirects or when multi-state authentication is used. Passing in -1 is
  47. a shortcut to "the last" request in the series, independently of the actual
  48. amount of requests used.
  49. It is suggested that you pass in the same \fBorigin\fP and \fBrequest\fP when
  50. iterating over a range of headers as changing the value mid-loop might give
  51. you unexpected results.
  52. If \fIprev\fP is NULL, this function returns a pointer to the first header
  53. stored within the given scope (origin + request).
  54. If \fIprev\fP is a pointer to a previously returned header struct,
  55. \fIcurl_easy_nextheader(3)\fP returns a pointer the next header stored within
  56. the given scope. This way, an application can iterate over all available
  57. headers.
  58. The memory for the struct this points to, is owned and managed by libcurl and
  59. is associated with the easy handle. Applications must copy the data if they
  60. want it to survive subsequent API calls or the life-time of the easy handle.
  61. .SH EXAMPLE
  62. .nf
  63. struct curl_header *prev = NULL;
  64. struct curl_header *h;
  65. /* extract the normal headers from the first request */
  66. while((h = curl_easy_nextheader(easy, CURLH_HEADER, 0, prev))) {
  67. print "%s: %s\\n", h->name, h->value);
  68. prev = h;
  69. }
  70. /* extract the normal headers + 1xx + trailers from the last request */
  71. unsigned int origin = CURLH_HEADER| CURLH_1XX | CURLH_TRAILER;
  72. while((h = curl_easy_nextheader(easy, origin, -1, prev))) {
  73. print "%s: %s\\n", h->name, h->value);
  74. prev = h;
  75. }
  76. .fi
  77. .SH AVAILABILITY
  78. Added in 7.83.0
  79. .SH RETURN VALUE
  80. This function returns the next header, or NULL when there are no more
  81. (matching) headers or an error occurred.
  82. If this function returns NULL when \fIprev\fP was set to NULL, then there are
  83. no headers available within the scope to return.
  84. .SH "SEE ALSO"
  85. .BR curl_easy_header "(3), " curl_easy_perform "(3) "