| 4 | using namespace acl; |
| 5 | |
| 6 | int 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…