-
Notifications
You must be signed in to change notification settings - Fork 0
/
httpclient_unittest.c
75 lines (63 loc) · 2.27 KB
/
httpclient_unittest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdio.h>
#include <stdlib.h>
#include "http_client.h"
int main(int argc, char **argv)
{
char *host = "125.211.218.8";
char *path = "/techqq/zt/2007/firacn/topic_html/xsm.htm";
/*
char *host = "10.205.42.139";
char *path = "/techqq/a/20090423/000378.htm";
char *path = "/techqq/a/20120111/000508.htm";
char *path = "/techqq/a/20121008/000013.htm";
char *path = "/techqq/wlyx.htm";
char *path = "/techqq/index.html";
char *path = "/techqq/a/20121008/000048.htm";
10.205.42.139:80/techqq/a/20090423/000378.htm
*/
const char *body_ptr;
int status;
http_client_t http_client1;
http_connect(&http_client1, host, 80);
http_do_get(&http_client1, path);
status = http_response_status(&http_client1);
body_ptr = http_response_body(&http_client1);
printf("---------------------Status-----------------------\n");
printf("%d\n", status);
printf("---------------------Body-----------------------\n");
printf("%p\n", body_ptr);
printf("%s\n", body_ptr);
http_disconnect(&http_client1);
/*
status = http_response_status(&http_client1);
body_ptr = http_response_body(&http_client1);
*/
/*
printf("---------------------Status-----------------------\n");
printf("%d\n", status);
printf("---------------------Body-----------------------\n");
printf("%s\n", body_ptr);
*/
/*
http_client_t http_client2;
http_connect(&http_client2, "ufp.umeng.com", 80);
http_do_get(&http_client2, "/login");
status = http_response_status(&http_client2);
body_ptr = http_response_body(&http_client2);
printf("---------------------Status-----------------------\n");
printf("%d\n", status);
printf("---------------------Body-----------------------\n");
printf("%s\n", body_ptr);
http_disconnect(&http_client2);
http_client_t http_client3;
http_connect(&http_client3, "blog.umeng.com", 80);
http_do_get(&http_client3, "/index.php/category/products/");
status = http_response_status(&http_client3);
body_ptr = http_response_body(&http_client3);
printf("---------------------Status-----------------------\n");
printf("%d\n", status);
printf("---------------------Body-----------------------\n");
printf("%s\n", body_ptr);
http_disconnect(&http_client3);
*/
}