From affe334675bf1f58c9d5d492dc6f6cd85524b32f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 10 Jan 2002 09:00:02 +0000 Subject: added http-post.c --- docs/examples/http-post.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 docs/examples/http-post.c (limited to 'docs/examples/http-post.c') diff --git a/docs/examples/http-post.c b/docs/examples/http-post.c new file mode 100644 index 000000000..1b4154fbf --- /dev/null +++ b/docs/examples/http-post.c @@ -0,0 +1,35 @@ +/***************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * $Id$ + */ + +#include +#include + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl = curl_easy_init(); + if(curl) { + /* First set the URL that is about to receive our POST. This URL can + just as well be a https:// URL if that is what should receive the + data. */ + curl_easy_setopt(curl, CURLOPT_URL, "http://postit.example.com/moo.cgi"); + /* Now specify the POST data */ + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl"); + + /* Perform the request, res will get the return code */ + res = curl_easy_perform(curl); + + /* always cleanup */ + curl_easy_cleanup(curl); + } + return 0; +} -- cgit v1.2.1 From 4207ef3d272513913785bd72c4686299f79cdcc4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 22 Nov 2004 14:41:36 +0000 Subject: removed trailing whitespace --- docs/examples/http-post.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'docs/examples/http-post.c') diff --git a/docs/examples/http-post.c b/docs/examples/http-post.c index 1b4154fbf..30ca3536b 100644 --- a/docs/examples/http-post.c +++ b/docs/examples/http-post.c @@ -1,8 +1,8 @@ /***************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * $Id$ -- cgit v1.2.1 From 0427b783e2ae554a118057d23c65f29041b7cb6e Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 18 May 2009 12:33:51 +0000 Subject: Add empty line, to force CVS to update the $Id date string format --- docs/examples/http-post.c | 1 + 1 file changed, 1 insertion(+) (limited to 'docs/examples/http-post.c') diff --git a/docs/examples/http-post.c b/docs/examples/http-post.c index 30ca3536b..bde06c6ea 100644 --- a/docs/examples/http-post.c +++ b/docs/examples/http-post.c @@ -33,3 +33,4 @@ int main(void) } return 0; } + -- cgit v1.2.1 From 4677778f854e2f8bfef70069d46c4c694cff859e Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 19 May 2009 12:12:22 +0000 Subject: Remove empty line used to force CVS to update the $Id date string format --- docs/examples/http-post.c | 1 - 1 file changed, 1 deletion(-) (limited to 'docs/examples/http-post.c') diff --git a/docs/examples/http-post.c b/docs/examples/http-post.c index bde06c6ea..30ca3536b 100644 --- a/docs/examples/http-post.c +++ b/docs/examples/http-post.c @@ -33,4 +33,3 @@ int main(void) } return 0; } - -- cgit v1.2.1 From 2309b4e330b96bc2e1f8e36b6184015e59544037 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 24 Mar 2010 11:02:54 +0100 Subject: remove the CVSish $Id$ lines --- docs/examples/http-post.c | 1 - 1 file changed, 1 deletion(-) (limited to 'docs/examples/http-post.c') diff --git a/docs/examples/http-post.c b/docs/examples/http-post.c index 30ca3536b..523177d28 100644 --- a/docs/examples/http-post.c +++ b/docs/examples/http-post.c @@ -5,7 +5,6 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * $Id$ */ #include -- cgit v1.2.1 From 1aeb635cdd296c16acb375a4a83a78f13166ccab Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 10 Mar 2011 11:48:02 +0100 Subject: sources: update source headers All C and H files now (should) feature the proper project curl source code header, which includes basic info, a copyright statement and some basic disclaimers. --- docs/examples/http-post.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'docs/examples/http-post.c') diff --git a/docs/examples/http-post.c b/docs/examples/http-post.c index 523177d28..22de628ca 100644 --- a/docs/examples/http-post.c +++ b/docs/examples/http-post.c @@ -1,12 +1,24 @@ -/***************************************************************************** +/*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - */ - + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ #include #include -- cgit v1.2.1 From a3dbbcfd2ac7ab8f597e26e76935726279d3fa0c Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Wed, 4 Jul 2012 17:03:52 +0200 Subject: Added error checking for samples. --- docs/examples/http-post.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'docs/examples/http-post.c') diff --git a/docs/examples/http-post.c b/docs/examples/http-post.c index 22de628ca..80f2b343b 100644 --- a/docs/examples/http-post.c +++ b/docs/examples/http-post.c @@ -38,6 +38,10 @@ int main(void) /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); + /* Check for errors */ + if(res != CURLE_OK) + fprintf(stderr, "curl_easy_perform() failed: %s\n", + curl_easy_strerror(res)); /* always cleanup */ curl_easy_cleanup(curl); -- cgit v1.2.1 From be795f90dac26c240ab64e1e1e156a66fa21db89 Mon Sep 17 00:00:00 2001 From: Guenter Knauf Date: Thu, 12 Jul 2012 02:02:22 +0200 Subject: Added curl_global_* functions. --- docs/examples/http-post.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'docs/examples/http-post.c') diff --git a/docs/examples/http-post.c b/docs/examples/http-post.c index 80f2b343b..f1975b1ec 100644 --- a/docs/examples/http-post.c +++ b/docs/examples/http-post.c @@ -27,6 +27,10 @@ int main(void) CURL *curl; CURLcode res; + /* In windows, this will init the winsock stuff */ + curl_global_init(CURL_GLOBAL_ALL); + + /* get a curl handle */ curl = curl_easy_init(); if(curl) { /* First set the URL that is about to receive our POST. This URL can @@ -46,5 +50,6 @@ int main(void) /* always cleanup */ curl_easy_cleanup(curl); } + curl_global_cleanup(); return 0; } -- cgit v1.2.1