1 /*****************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
15 /* For Windows, mainly (may be moved in a config file?) */
17 #define STDIN_FILENO 0
20 #define STDOUT_FILENO 1
23 #define STDERR_FILENO 2
31 if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
32 fprintf(stderr, "curl_global_init() failed\n");
33 return TEST_ERR_MAJOR_BAD;
36 if ((curl = curl_easy_init()) == NULL) {
37 fprintf(stderr, "curl_easy_init() failed\n");
38 curl_global_cleanup();
39 return TEST_ERR_MAJOR_BAD;
42 curl_easy_setopt(curl, CURLOPT_URL, URL);
43 curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
45 res = curl_easy_perform(curl);
48 /* we are connected, now get a HTTP document the raw way */
49 const char *request = "GET /556 HTTP/1.2\r\n"
50 "Host: ninja\r\n\r\n";
54 res = curl_easy_send(curl, request, strlen(request), &iolen);
57 /* we assume that sending always work */
61 /* busy-read like crazy */
62 res = curl_easy_recv(curl, buf, 1024, &iolen);
65 /* send received stuff to stdout */
66 write(STDOUT_FILENO, buf, iolen);
69 } while(((res == CURLE_OK) || (res == CURLE_AGAIN)) && (total < 129));
74 curl_easy_cleanup(curl);
75 curl_global_cleanup();