Mercurial
annotate seobeo/tests/seobeo_client_test.c @ 151:c033667da5f9 hg-web
Merging latest merge into hg-web
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Sat, 10 Jan 2026 13:35:09 -0800 |
| parents | c39582f937e5 |
| children |
| rev | line source |
|---|---|
|
119
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1 #include "seobeo/seobeo.h" |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2 #include <stdio.h> |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3 #include <stdlib.h> |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5 void Test_Simple_Get() |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
6 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
7 printf("\n=== Test 1: Simple GET Request ===\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
8 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
9 Seobeo_Client_Request *p_req = Seobeo_Client_Request_Create("https://httpbin.org/get"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
10 if (!p_req) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
11 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
12 printf("Failed to create request\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
13 return; |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
14 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
15 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
16 Seobeo_Client_Response *p_resp = Seobeo_Client_Request_Execute(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
17 if (p_resp) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
18 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
19 printf("Status: %d %s\n", p_resp->status_code, p_resp->status_text ? p_resp->status_text : ""); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
20 printf("Body length: %zu bytes\n", p_resp->body_length); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
21 if (p_resp->body && p_resp->body_length > 0) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
22 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
23 printf("Body preview: %.200s...\n", p_resp->body); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
24 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
25 Seobeo_Client_Response_Destroy(p_resp); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
26 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
27 else |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
28 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
29 printf("Request failed\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
30 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
31 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
32 Seobeo_Client_Request_Destroy(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
33 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
34 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
35 void Test_Custom_Headers_HashMap() |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
36 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
37 printf("\n=== Test 2: Custom Headers using HashMap ===\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
38 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
39 Seobeo_Client_Request *p_req = Seobeo_Client_Request_Create("https://httpbin.org/headers"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
40 if (!p_req) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
41 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
42 printf("Failed to create request\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
43 return; |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
44 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
45 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
46 Seobeo_Client_Request_Add_Header_Map(p_req, "User-Agent", "Seobeo/1.0"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
47 Seobeo_Client_Request_Add_Header_Map(p_req, "Accept", "application/json"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
48 Seobeo_Client_Request_Add_Header_Map(p_req, "X-Custom-Header", "CustomValue"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
49 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
50 Seobeo_Client_Response *p_resp = Seobeo_Client_Request_Execute(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
51 if (p_resp) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
52 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
53 printf("Status: %d\n", p_resp->status_code); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
54 if (p_resp->body) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
55 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
56 printf("Response:\n%s\n", p_resp->body); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
57 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
58 Seobeo_Client_Response_Destroy(p_resp); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
59 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
60 else |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
61 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
62 printf("Request failed\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
63 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
64 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
65 Seobeo_Client_Request_Destroy(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
66 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
67 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
68 void Test_Custom_Headers_Array() |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
69 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
70 printf("\n=== Test 3: Custom Headers using Array ===\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
71 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
72 Seobeo_Client_Request *p_req = Seobeo_Client_Request_Create("https://httpbin.org/headers"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
73 if (!p_req) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
74 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
75 printf("Failed to create request\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
76 return; |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
77 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
78 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
79 Seobeo_Client_Request_Add_Header_Array(p_req, "User-Agent: Seobeo/1.0 (Array Mode)"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
80 Seobeo_Client_Request_Add_Header_Array(p_req, "Accept: application/json"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
81 Seobeo_Client_Request_Add_Header_Array(p_req, "X-Test-Header: TestValue"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
82 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
83 Seobeo_Client_Response *p_resp = Seobeo_Client_Request_Execute(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
84 if (p_resp) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
85 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
86 printf("Status: %d\n", p_resp->status_code); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
87 if (p_resp->body) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
88 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
89 printf("Response:\n%s\n", p_resp->body); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
90 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
91 Seobeo_Client_Response_Destroy(p_resp); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
92 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
93 else |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
94 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
95 printf("Request failed\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
96 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
97 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
98 Seobeo_Client_Request_Destroy(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
99 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
100 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
101 void Test_Post_With_Body() |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
102 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
103 printf("\n=== Test 4: POST Request with Body ===\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
104 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
105 Seobeo_Client_Request *p_req = Seobeo_Client_Request_Create("https://httpbin.org/post"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
106 if (!p_req) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
107 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
108 printf("Failed to create request\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
109 return; |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
110 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
111 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
112 Seobeo_Client_Request_Set_Method(p_req, "POST"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
113 Seobeo_Client_Request_Add_Header_Map(p_req, "Content-Type", "application/json"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
114 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
115 const char *json_body = "{\"name\": \"Seobeo\", \"version\": \"1.0\", \"message\": \"Hello from Seobeo HTTP Client!\"}"; |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
116 Seobeo_Client_Request_Set_Body(p_req, json_body, 0); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
117 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
118 Seobeo_Client_Response *p_resp = Seobeo_Client_Request_Execute(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
119 if (p_resp) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
120 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
121 printf("Status: %d\n", p_resp->status_code); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
122 if (p_resp->body) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
123 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
124 printf("Response:\n%s\n", p_resp->body); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
125 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
126 Seobeo_Client_Response_Destroy(p_resp); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
127 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
128 else |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
129 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
130 printf("Request failed\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
131 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
132 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
133 Seobeo_Client_Request_Destroy(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
134 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
135 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
136 void Test_Follow_Redirects() |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
137 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
138 printf("\n=== Test 5: Following Redirects ===\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
139 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
140 Seobeo_Client_Request *p_req = Seobeo_Client_Request_Create("https://httpbin.org/redirect/2"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
141 if (!p_req) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
142 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
143 printf("Failed to create request\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
144 return; |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
145 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
146 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
147 Seobeo_Client_Request_Set_Follow_Redirects(p_req, TRUE, 10); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
148 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
149 Seobeo_Client_Response *p_resp = Seobeo_Client_Request_Execute(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
150 if (p_resp) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
151 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
152 printf("Final Status: %d\n", p_resp->status_code); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
153 printf("Body length: %zu bytes\n", p_resp->body_length); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
154 Seobeo_Client_Response_Destroy(p_resp); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
155 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
156 else |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
157 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
158 printf("Request failed\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
159 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
160 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
161 Seobeo_Client_Request_Destroy(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
162 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
163 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
164 void Test_Download_File() |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
165 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
166 printf("\n=== Test 6: Download File ===\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
167 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
168 Seobeo_Client_Request *p_req = Seobeo_Client_Request_Create("https://mrjunejune.com/public/epi_favicon.svg"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
169 if (!p_req) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
170 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
171 printf("Failed to create request\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
172 return; |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
173 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
174 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
175 Seobeo_Client_Request_Set_Download_Path(p_req, "downloaded_example.html"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
176 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
177 Seobeo_Client_Response *p_resp = Seobeo_Client_Request_Execute(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
178 if (p_resp) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
179 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
180 printf("Status: %d\n", p_resp->status_code); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
181 printf("Downloaded %zu bytes to 'downloaded_example.html'\n", p_resp->body_length); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
182 Seobeo_Client_Response_Destroy(p_resp); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
183 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
184 else |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
185 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
186 printf("Request failed\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
187 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
188 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
189 Seobeo_Client_Request_Destroy(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
190 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
191 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
192 void Test_Mixed_Headers() |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
193 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
194 printf("\n=== Test 7: Mixed HashMap and Array Headers ===\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
195 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
196 Seobeo_Client_Request *p_req = Seobeo_Client_Request_Create("https://httpbin.org/headers"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
197 if (!p_req) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
198 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
199 printf("Failed to create request\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
200 return; |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
201 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
202 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
203 Seobeo_Client_Request_Add_Header_Map(p_req, "User-Agent", "Seobeo/1.0"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
204 Seobeo_Client_Request_Add_Header_Map(p_req, "Accept", "application/json"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
205 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
206 Seobeo_Client_Request_Add_Header_Array(p_req, "X-Custom-1: Value1"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
207 Seobeo_Client_Request_Add_Header_Array(p_req, "X-Custom-2: Value2"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
208 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
209 Seobeo_Client_Response *p_resp = Seobeo_Client_Request_Execute(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
210 if (p_resp) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
211 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
212 printf("Status: %d\n", p_resp->status_code); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
213 if (p_resp->body) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
214 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
215 printf("Response:\n%s\n", p_resp->body); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
216 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
217 Seobeo_Client_Response_Destroy(p_resp); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
218 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
219 else |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
220 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
221 printf("Request failed\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
222 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
223 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
224 Seobeo_Client_Request_Destroy(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
225 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
226 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
227 void Test_Response_Headers() |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
228 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
229 printf("\n=== Test 8: Accessing Response Headers ===\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
230 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
231 Seobeo_Client_Request *p_req = Seobeo_Client_Request_Create("https://httpbin.org/get"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
232 if (!p_req) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
233 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
234 printf("Failed to create request\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
235 return; |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
236 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
237 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
238 Seobeo_Client_Response *p_resp = Seobeo_Client_Request_Execute(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
239 if (p_resp) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
240 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
241 printf("Status: %d %s\n", p_resp->status_code, p_resp->status_text ? p_resp->status_text : ""); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
242 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
243 if (p_resp->headers) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
244 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
245 printf("\nResponse Headers:\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
246 size_t count = Dowa_Array_Length(p_resp->headers); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
247 for (size_t i = 0; i < count; i++) |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
248 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
249 printf(" %s: %s\n", p_resp->headers[i].key, p_resp->headers[i].value); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
250 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
251 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
252 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
253 Seobeo_Client_Response_Destroy(p_resp); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
254 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
255 else |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
256 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
257 printf("Request failed\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
258 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
259 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
260 Seobeo_Client_Request_Destroy(p_req); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
261 } |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
262 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
263 int main() |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
264 { |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
265 printf("=== Seobeo HTTP Client Tests ===\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
266 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
267 Test_Simple_Get(); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
268 Test_Custom_Headers_HashMap(); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
269 Test_Custom_Headers_Array(); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
270 Test_Post_With_Body(); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
271 Test_Follow_Redirects(); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
272 Test_Download_File(); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
273 Test_Mixed_Headers(); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
274 Test_Response_Headers(); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
275 |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
276 printf("\n=== All Tests Completed ===\n"); |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
277 return 0; |
|
c39582f937e5
[Seobeo Client] Added client side logic which will be used for all my other calls instead of curl.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
278 } |