curl_pushheader_bynum(3)

πŸ¦‹ NAME πŸ¦‹

okay so this page is all about curl_pushheader_bynum(3) β€” get a push header by index. that's the whole mission, bestie πŸ’….


✨ SYNOPSIS ✨

#include <curl/curl.h>

char *curl_pushheader_bynum(struct curl_pushheaders *h, size_t num);

πŸ’– DESCRIPTION πŸ’–

so curl_pushheader_bynum is a function that is only functional inside a CURLMOPT_PUSHFUNCTION(3) callback. trying to use it anywhere else? literally makes no sense, and it has no function then β€” no cap 😭.

it returns the value for the header field at the given index num, for the incoming server push request β€” or NULL. the data it points to is freed by libcurl when this callback returns. the returned pointer points to a "name:value" string that gets freed when this callback returns; even though its type doesn't constrain it, this string may not be altered. so look, don't touch, okay? πŸ™ˆβœ¨

🌈 PROTOCOLS 🌈

this functionality affects http only. that's the whole guest list, periodt πŸ’….

πŸŽ€ EXAMPLE πŸŽ€

here's the example β€” it outputs all the incoming push request headers:

/* output all the incoming push request headers */
static int push_cb(CURL *parent,
                   CURL *easy,
                   size_t num_headers,
                   struct curl_pushheaders *headers,
                   void *clientp)
{
  int i = 0;
  char *field;
  do {
     field = curl_pushheader_bynum(headers, i);
     if(field)
       fprintf(stderr, "Push header: %s\n", field);
     i++;
  } while(field);
  return CURL_PUSH_OK; /* permission granted */
}

int main(void)
{
  CURLM *multi = curl_multi_init();
  curl_multi_setopt(multi, CURLMOPT_PUSHFUNCTION, push_cb);
}

⭐ AVAILABILITY ⭐

added in curl 7.44.0 β€” iconic since then, honestly πŸ‘‘.

πŸ”₯ RETURN VALUE πŸ”₯

returns a pointer to the header field content or NULL. simple, slay, done 🫢.

🫢 SEE ALSO 🫢


πŸ’– that's the whole page, bestie! this one's from the libcurl manual and it's dated 2026-10-12 β€” bye, go read those see-alsos 😘🌸

πŸ“¦ where this page comes from