lib1536.c
Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                  _   _ ____  _
00003  *  Project                     ___| | | |  _ \| |
00004  *                             / __| | | | |_) | |
00005  *                            | (__| |_| |  _ <| |___
00006  *                             \___|\___/|_| \_\_____|
00007  *
00008  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00009  *
00010  * This software is licensed as described in the file COPYING, which
00011  * you should have received as part of this distribution. The terms
00012  * are also available at https://curl.haxx.se/docs/copyright.html.
00013  *
00014  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00015  * copies of the Software, and permit persons to whom the Software is
00016  * furnished to do so, under the terms of the COPYING file.
00017  *
00018  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00019  * KIND, either express or implied.
00020  *
00021  ***************************************************************************/
00022 #include "test.h"
00023 
00024 #include "memdebug.h"
00025 
00026 /* Test CURLINFO_SCHEME */
00027 
00028 int test(char *URL)
00029 {
00030   CURL *curl, *dupe = NULL;
00031   char *scheme;
00032   int res = CURLE_OK;
00033 
00034   global_init(CURL_GLOBAL_ALL);
00035 
00036   easy_init(curl);
00037 
00038   /* Test that scheme is properly initialized on curl_easy_init.
00039   */
00040 
00041   res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
00042   if(res) {
00043     fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
00044             __FILE__, __LINE__, res, curl_easy_strerror(res));
00045     goto test_cleanup;
00046   }
00047   if(scheme != NULL) {
00048     fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
00049             __FILE__, __LINE__);
00050     res = CURLE_FAILED_INIT;
00051     goto test_cleanup;
00052   }
00053 
00054   easy_setopt(curl, CURLOPT_URL, URL);
00055 
00056   res = curl_easy_perform(curl);
00057   if(res) {
00058     fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
00059             __FILE__, __LINE__, res, curl_easy_strerror(res));
00060     goto test_cleanup;
00061   }
00062 
00063   /* Test that a scheme is properly set after receiving an HTTP resource.
00064   */
00065 
00066   res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
00067   if(res) {
00068     fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
00069             __FILE__, __LINE__, res, curl_easy_strerror(res));
00070     goto test_cleanup;
00071   }
00072   if(memcmp(scheme, "HTTP", 5) != 0) {
00073     fprintf(stderr, "%s:%d scheme of http resource is incorrect; "
00074             "expected 'HTTP' but is %s\n",
00075             __FILE__, __LINE__, CURLPROTO_HTTP,
00076             (scheme == NULL ? "NULL" : "invalid"));
00077     res = CURLE_HTTP_RETURNED_ERROR;
00078     goto test_cleanup;
00079   }
00080 
00081   /* Test that a scheme is properly initialized on curl_easy_duphandle.
00082   */
00083 
00084   dupe = curl_easy_duphandle(curl);
00085   if(!dupe) {
00086     fprintf(stderr, "%s:%d curl_easy_duphandle() failed\n",
00087             __FILE__, __LINE__);
00088     res = CURLE_FAILED_INIT;
00089     goto test_cleanup;
00090   }
00091 
00092   res = curl_easy_getinfo(dupe, CURLINFO_SCHEME, &scheme);
00093   if(res) {
00094     fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
00095             __FILE__, __LINE__, res, curl_easy_strerror(res));
00096     goto test_cleanup;
00097   }
00098   if(scheme != 0) {
00099     fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
00100             __FILE__, __LINE__);
00101     res = CURLE_FAILED_INIT;
00102     goto test_cleanup;
00103   }
00104 
00105 
00106   /* Test that a scheme is properly initialized on curl_easy_reset.
00107   */
00108 
00109   curl_easy_reset(curl);
00110 
00111   res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
00112   if(res) {
00113     fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
00114             __FILE__, __LINE__, res, curl_easy_strerror(res));
00115     goto test_cleanup;
00116   }
00117   if(scheme != 0) {
00118     fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
00119             __FILE__, __LINE__);
00120     res = CURLE_FAILED_INIT;
00121     goto test_cleanup;
00122   }
00123 
00124 test_cleanup:
00125   curl_easy_cleanup(curl);
00126   curl_easy_cleanup(dupe);
00127   curl_global_cleanup();
00128   return res;
00129 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05