MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl_cpp/samples/http_test/main.cpp:6–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4using namespace acl;
5
6int main(void)
7{
8 const char* url = "https://127.0.0.1:9001";
9 acl::http_url parser;
10 if (!parser.parse(url)) {
11 printf("invalid url\n");
12 return 1;
13 }
14 printf("domain=%s, port=%d, url=%s\r\n", parser.get_domain(), parser.get_port(), parser.get_url_path());
15
16 return 0;
17
18 const char* data = "U_TRS1=000000f6.66721803.4fd1681c.8c48b73a; path=/; expires=Mon, 06-Jun-22 02:49:00 GMT; domain=.sina.com.cn";
19 HttpCookie* cookie = new HttpCookie();
20
21 printf("Set-Cookie: %s\r\n", data);
22
23 if (cookie->setCookie(data) == false)
24 {
25 printf("parse cookie(%s) error\r\n", data);
26 cookie->destroy();
27 return -1;
28 }
29
30 printf("cookie name: %s\r\n", cookie->getName());
31 printf("cookie value: %s\r\n", cookie->getValue());
32 printf("domain: %s\r\n", cookie->getDomain());
33 printf("path: %s\r\n", cookie->getPath());
34 printf("max-age: %d\r\n", cookie->getMaxAge());
35
36 const std::list<HTTP_PARAM*>& params = cookie->getParams();
37 std::list<HTTP_PARAM*>::const_iterator cit = params.begin();
38 for (; cit != params.end(); ++cit)
39 printf(">>%s=%s\r\n", (*cit)->name, (*cit)->value);
40
41 cookie->destroy();
42
43 const char* s = "encrypted/json";
44 acl::http_ctype hc;
45 if (hc.parse(s)) {
46 const char* ctype = hc.get_ctype();
47 const char* stype = hc.get_stype();
48 printf("ctype=%s, stype=%s\r\n", ctype, stype);
49 }
50 return 0;
51}

Callers

nothing calls this directly

Calls 14

getDomainMethod · 0.80
getPathMethod · 0.80
getMaxAgeMethod · 0.80
beginMethod · 0.80
parseMethod · 0.45
get_domainMethod · 0.45
get_portMethod · 0.45
setCookieMethod · 0.45
destroyMethod · 0.45
getNameMethod · 0.45
getValueMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…