00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef DEBUG
00019 #define DEBUG
00020 #endif
00021
00022 #include <ucommon-config.h>
00023 #include <ucommon/secure.h>
00024
00025 #include <stdio.h>
00026
00027 using namespace UCOMMON_NAMESPACE;
00028
00029 int main(int argc, char **argv)
00030 {
00031 const char *proto = "80";
00032 secure::client_t ctx = NULL;
00033
00034 if(secure::init()) {
00035 proto = "443";
00036 ctx = secure::client();
00037 }
00038
00039 printf("protocol %s\n", proto);
00040
00041 if(ctx)
00042 printf("ctx %p %d\n", (void *)ctx, ctx->err());
00043
00044 ssl_t ssl(ctx);
00045 ssl.open("www.google.com", proto);
00046 printf("open %d\n", ssl.is_open());
00047
00048 ssl.putline("GET /\r\n\r\n");
00049 ssl.flush();
00050
00051 char buf[256];
00052
00053 while(!ssl.eof()) {
00054 ssl.getline(buf, sizeof(buf));
00055 printf("%s\n", buf);
00056 }
00057
00058 ssl.close();
00059 }
00060
00061