~ubuntu-branches/ubuntu/lucid/curl/lucid-201010031940

« back to all changes in this revision

Viewing changes to tests/libtest/lib556.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2009-05-26 18:58:51 UTC
  • mfrom: (3.3.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090526185851-t1gun9nboi5kbd9u
Tags: 7.19.5-1ubuntu1
* Merge from Debian unstable (LP: #380281), remaining changes:
  - Drop build dependencies: stunnel, libdb4.6-dev, libssh2-1-dev
  - Add build-dependency on openssh-server
  - Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.
  - Call automake-1.9 with --add-missing --copy --force
* Fixes LP: #379477

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * $Id: lib556.c,v 1.4 2008-09-20 04:26:57 yangtse Exp $
 
8
 * $Id: lib556.c,v 1.7 2009-05-08 02:14:50 yangtse Exp $
9
9
 */
10
10
 
11
11
#include "test.h"
12
12
 
13
13
#include "memdebug.h"
14
14
 
 
15
/* For Windows, mainly (may be moved in a config file?) */
 
16
#ifndef STDIN_FILENO
 
17
  #define STDIN_FILENO 0
 
18
#endif
 
19
#ifndef STDOUT_FILENO
 
20
  #define STDOUT_FILENO 1
 
21
#endif
 
22
#ifndef STDERR_FILENO
 
23
  #define STDERR_FILENO 2
 
24
#endif
 
25
 
15
26
int test(char *URL)
16
27
{
17
28
  CURLcode res;
35
46
 
36
47
  if(!res) {
37
48
    /* we are connected, now get a HTTP document the raw way */
38
 
    const char *request = "GET /556 HTTP/1.2\r\n"
 
49
    const char *request = 
 
50
#ifdef CURL_DOES_CONVERSIONS
 
51
      /* ASCII representation with escape sequences for non-ASCII platforms */
 
52
      "\x47\x45\x54\x20\x2f\x35\x35\x36\x20\x48\x54\x54\x50\x2f\x31\x2e"
 
53
      "\x32\x0d\x0a\x48\x6f\x73\x74\x3a\x20\x6e\x69\x6e\x6a\x61\x0d\x0a"
 
54
      "\x0d\x0a";
 
55
#else
 
56
      "GET /556 HTTP/1.2\r\n"
39
57
      "Host: ninja\r\n\r\n";
 
58
#endif
40
59
    size_t iolen;
41
60
    char buf[1024];
42
61
 
44
63
 
45
64
    if(!res) {
46
65
      /* we assume that sending always work */
47
 
      int total=0;
 
66
      size_t total=0;
48
67
 
49
68
      do {
50
69
        /* busy-read like crazy */
51
70
        res = curl_easy_recv(curl, buf, 1024, &iolen);
52
71
 
 
72
#ifdef TPF
 
73
        sleep(1); /* avoid ctl-10 dump */
 
74
#endif
 
75
 
53
76
        if(iolen)
54
77
          /* send received stuff to stdout */
55
78
          write(STDOUT_FILENO, buf, iolen);
56
 
 
57
79
        total += iolen;
58
80
 
59
81
      } while(((res == CURLE_OK) || (res == CURLE_AGAIN)) && (total < 129));