4822l4

Listing 4. Reading the Response

48      while(1){
49        r=SSL_read(ssl,buf,BUFSIZZ);
50        switch(SSL_get_error(ssl,r)){
51          case SSL_ERROR_NONE:
52            len=r;
53            break;
54          case SSL_ERROR_ZERO_RETURN:
55            goto shutdown;
56          case SSL_ERROR_SYSCALL:
57            fprintf(stderr,
58              "SSL Error: Premature close\n");
59            goto done;
60          default:
61            berr_exit("SSL read problem");
62        }
63
64        fwrite(buf,1,len,stdout);
65      }
