1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, Vijay Panghal, <vpanghal@maginatics.com>, et al.
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 https://curl.haxx.se/docs/copyright.html.
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.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
24 * This unit test PUT http data over proxy. Same http header will be generated
25 * for server and proxy
32 static char data [] = "Hello Cloud!\n";
34 static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream)
36 size_t amount = nmemb * size; /* Total bytes curl wants */
37 if(amount < strlen(data)) {
41 memcpy(ptr, data, strlen(data));
49 CURLcode res = CURLE_FAILED_INIT;
51 struct curl_slist *hhl = NULL, *tmp = NULL;
53 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
54 fprintf(stderr, "curl_global_init() failed\n");
55 return TEST_ERR_MAJOR_BAD;
58 curl = curl_easy_init();
60 fprintf(stderr, "curl_easy_init() failed\n");
61 curl_global_cleanup();
62 return TEST_ERR_MAJOR_BAD;
65 hhl = curl_slist_append(hhl, "User-Agent: Http Agent");
69 tmp = curl_slist_append(hhl, "Expect: 100-continue");
75 test_setopt(curl, CURLOPT_URL, URL);
76 test_setopt(curl, CURLOPT_PROXY, libtest_arg2);
77 test_setopt(curl, CURLOPT_HTTPHEADER, hhl);
78 test_setopt(curl, CURLOPT_POST, 0L);
79 test_setopt(curl, CURLOPT_UPLOAD, 1L);
80 test_setopt(curl, CURLOPT_VERBOSE, 1L);
81 test_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
82 test_setopt(curl, CURLOPT_HEADER, 1L);
83 test_setopt(curl, CURLOPT_WRITEFUNCTION, fwrite);
84 test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
85 test_setopt(curl, CURLOPT_HTTPPROXYTUNNEL, 1L);
86 test_setopt(curl, CURLOPT_INFILESIZE, (long)strlen(data));
87 test_setopt(curl, CURLOPT_HEADEROPT, CURLHEADER_UNIFIED);
89 res = curl_easy_perform(curl);
93 curl_easy_cleanup(curl);
95 curl_slist_free_all(hhl);
97 curl_global_cleanup();