1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
14 /* For Windows, mainly (may be moved in a config file?) */
16 #define STDIN_FILENO 0
19 #define STDOUT_FILENO 1
22 #define STDERR_FILENO 2
30 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
31 fprintf(stderr, "curl_global_init() failed\n");
32 return TEST_ERR_MAJOR_BAD;
35 if ((curl = curl_easy_init()) == NULL) {
36 fprintf(stderr, "curl_easy_init() failed\n");
37 curl_global_cleanup();
38 return TEST_ERR_MAJOR_BAD;
41 test_setopt(curl, CURLOPT_URL, URL);
42 test_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
44 res = curl_easy_perform(curl);
47 /* we are connected, now get a HTTP document the raw way */
49 #ifdef CURL_DOES_CONVERSIONS
50 /* ASCII representation with escape sequences for non-ASCII platforms */
51 "\x47\x45\x54\x20\x2f\x35\x35\x36\x20\x48\x54\x54\x50\x2f\x31\x2e"
52 "\x32\x0d\x0a\x48\x6f\x73\x74\x3a\x20\x6e\x69\x6e\x6a\x61\x0d\x0a"
55 "GET /556 HTTP/1.2\r\n"
56 "Host: ninja\r\n\r\n";
61 res = curl_easy_send(curl, request, strlen(request), &iolen);
64 /* we assume that sending always work */
68 /* busy-read like crazy */
69 res = curl_easy_recv(curl, buf, 1024, &iolen);
72 sleep(1); /* avoid ctl-10 dump */
76 /* send received stuff to stdout */
77 write(STDOUT_FILENO, buf, iolen);
80 } while(((res == CURLE_OK) || (res == CURLE_AGAIN)) && (total < 129));
86 curl_easy_cleanup(curl);
87 curl_global_cleanup();