~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to docs/examples/httpcustomheader.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Schuldei
  • Date: 2009-04-02 23:35:45 UTC
  • mto: (1.2.1 upstream) (3.2.3 sid)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20090402233545-geixkwhe3izccjt7
Tags: upstream-7.19.4
ImportĀ upstreamĀ versionĀ 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 *                                  _   _ ____  _
 
3
 *  Project                     ___| | | |  _ \| |
 
4
 *                             / __| | | | |_) | |
 
5
 *                            | (__| |_| |  _ <| |___
 
6
 *                             \___|\___/|_| \_\_____|
 
7
 *
 
8
 * $Id: httpcustomheader.c,v 1.2 2009-01-12 21:29:23 bagder Exp $
 
9
 */
 
10
 
 
11
#include <stdio.h>
 
12
#include <curl/curl.h>
 
13
 
 
14
int main(void)
 
15
{
 
16
  CURL *curl;
 
17
  CURLcode res;
 
18
 
 
19
  curl = curl_easy_init();
 
20
  if(curl) {
 
21
    struct curl_slist *chunk = NULL;
 
22
 
 
23
    chunk = curl_slist_append(chunk, "Accept: moo");
 
24
    chunk = curl_slist_append(chunk, "Another: yes");
 
25
 
 
26
    /* request with the built-in Accept: */
 
27
    curl_easy_setopt(curl, CURLOPT_URL, "localhost");
 
28
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
 
29
    res = curl_easy_perform(curl);
 
30
 
 
31
    /* redo request with our own custom Accept: */
 
32
    res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
 
33
    res = curl_easy_perform(curl);
 
34
 
 
35
    /* always cleanup */
 
36
    curl_easy_cleanup(curl);
 
37
  }
 
38
  return 0;
 
39
}