1/*************************************************************************** 2 * _ _ ____ _ 3 * Project ___| | | | _ \| | 4 * / __| | | | |_) | | 5 * | (__| |_| | _ <| |___ 6 * \___|\___/|_| \_\_____| 7 * 8 * Copyright (C) 1998 - 2011, 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 http://curl.haxx.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#include "test.h" 23 24#ifdef HAVE_SYS_SOCKET_H 25#include <sys/socket.h> 26#endif 27#ifdef HAVE_SYS_TYPES_H 28#include <sys/types.h> 29#endif 30#ifdef HAVE_SYS_STAT_H 31#include <sys/stat.h> 32#endif 33#ifdef HAVE_FCNTL_H 34#include <fcntl.h> 35#endif 36 37#ifdef HAVE_UNISTD_H 38#include <unistd.h> 39#endif 40 41#include "memdebug.h" 42 43/* 44 * FTP get with NOBODY but no HEADER 45 */ 46 47int test(char *URL) 48{ 49 CURL *curl; 50 CURLcode res = CURLE_OK; 51 52 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { 53 fprintf(stderr, "curl_global_init() failed\n"); 54 return TEST_ERR_MAJOR_BAD; 55 } 56 57 /* get a curl handle */ 58 if ((curl = curl_easy_init()) == NULL) { 59 fprintf(stderr, "curl_easy_init() failed\n"); 60 curl_global_cleanup(); 61 return TEST_ERR_MAJOR_BAD; 62 } 63 64 /* enable verbose */ 65 test_setopt(curl, CURLOPT_VERBOSE, 1L); 66 67 /* enable NOBODY */ 68 test_setopt(curl, CURLOPT_NOBODY, 1L); 69 70 /* disable HEADER */ 71 test_setopt(curl, CURLOPT_HEADER, 0L); 72 73 /* specify target */ 74 test_setopt(curl,CURLOPT_URL, URL); 75 76 /* Now run off and do what you've been told! */ 77 res = curl_easy_perform(curl); 78 79test_cleanup: 80 81 curl_easy_cleanup(curl); 82 curl_global_cleanup(); 83 84 return res; 85} 86