aboutsummaryrefslogtreecommitdiff
path: root/tests/libtest/lib510.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libtest/lib510.c')
-rw-r--r--tests/libtest/lib510.c60
1 files changed, 37 insertions, 23 deletions
diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c
index 4dfdbd962..6c1269a86 100644
--- a/tests/libtest/lib510.c
+++ b/tests/libtest/lib510.c
@@ -41,42 +41,56 @@ int test(char *URL)
struct WriteThis pooh;
pooh.counter = 0;
- slist = curl_slist_append(slist, "Transfer-Encoding: chunked");
+ if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+ fprintf(stderr, "curl_global_init() failed\n");
+ return TEST_ERR_MAJOR_BAD;
+ }
- curl = curl_easy_init();
- if(curl) {
- /* First set the URL that is about to receive our POST. */
- curl_easy_setopt(curl, CURLOPT_URL, URL);
+ if ((curl = curl_easy_init()) == NULL) {
+ fprintf(stderr, "curl_easy_init() failed\n");
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
- /* Now specify we want to POST data */
- curl_easy_setopt(curl, CURLOPT_POST, TRUE);
+ slist = curl_slist_append(slist, "Transfer-Encoding: chunked");
+ if (slist == NULL) {
+ fprintf(stderr, "curl_slist_append() failed\n");
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+ return TEST_ERR_MAJOR_BAD;
+ }
- /* we want to use our own read function */
- curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
+ /* First set the URL that is about to receive our POST. */
+ curl_easy_setopt(curl, CURLOPT_URL, URL);
- /* pointer to pass to our read function */
- curl_easy_setopt(curl, CURLOPT_INFILE, &pooh);
+ /* Now specify we want to POST data */
+ curl_easy_setopt(curl, CURLOPT_POST, TRUE);
- /* get verbose debug output please */
- curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+ /* we want to use our own read function */
+ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
- /* include headers in the output */
- curl_easy_setopt(curl, CURLOPT_HEADER, TRUE);
+ /* pointer to pass to our read function */
+ curl_easy_setopt(curl, CURLOPT_INFILE, &pooh);
- /* enforce chunked transfer by setting the header */
- curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
+ /* get verbose debug output please */
+ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
- /* Perform the request, res will get the return code */
- res = curl_easy_perform(curl);
+ /* include headers in the output */
+ curl_easy_setopt(curl, CURLOPT_HEADER, TRUE);
- /* always cleanup */
- curl_easy_cleanup(curl);
+ /* enforce chunked transfer by setting the header */
+ curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist);
- }
+ /* Perform the request, res will get the return code */
+ res = curl_easy_perform(curl);
+ /* clean up the headers list */
if(slist)
- /* clean up the headers list */
curl_slist_free_all(slist);
+ /* always cleanup */
+ curl_easy_cleanup(curl);
+ curl_global_cleanup();
+
return res;
}