1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, 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 ***************************************************************************/
27 /* For Windows, mainly (may be moved in a config file?) */
29 #define STDIN_FILENO 0
32 #define STDOUT_FILENO 1
35 #define STDERR_FILENO 2
43 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
44 fprintf(stderr, "curl_global_init() failed\n");
45 return TEST_ERR_MAJOR_BAD;
48 curl = curl_easy_init();
50 fprintf(stderr, "curl_easy_init() failed\n");
51 curl_global_cleanup();
52 return TEST_ERR_MAJOR_BAD;
55 test_setopt(curl, CURLOPT_URL, URL);
56 test_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
57 test_setopt(curl, CURLOPT_VERBOSE, 1L);
59 res = curl_easy_perform(curl);
62 /* we are connected, now get a HTTP document the raw way */
64 #ifdef CURL_DOES_CONVERSIONS
65 /* ASCII representation with escape sequences for non-ASCII platforms */
66 "\x47\x45\x54\x20\x2f\x35\x35\x36\x20\x48\x54\x54\x50\x2f\x31\x2e"
67 "\x32\x0d\x0a\x48\x6f\x73\x74\x3a\x20\x6e\x69\x6e\x6a\x61\x0d\x0a"
70 "GET /556 HTTP/1.2\r\n"
71 "Host: ninja\r\n\r\n";
76 res = curl_easy_send(curl, request, strlen(request), &iolen);
79 /* we assume that sending always work */
82 /* busy-read like crazy */
83 res = curl_easy_recv(curl, buf, sizeof(buf), &iolen);
86 sleep(1); /* avoid ctl-10 dump */
90 /* send received stuff to stdout */
91 if(!write(STDOUT_FILENO, buf, iolen))
95 } while((res == CURLE_OK && iolen != 0) || (res == CURLE_AGAIN));
99 res = TEST_ERR_FAILURE;
104 curl_easy_cleanup(curl);
105 curl_global_cleanup();