| 109 | } |
| 110 | |
| 111 | void HttpCookie::writeFile() { |
| 112 | FILE *out; |
| 113 | out = fopen(_cookieFileName.c_str(), "w"); |
| 114 | fputs( |
| 115 | "# Netscape HTTP Cookie File\n" |
| 116 | "# http://curl.haxx.se/docs/http-cookies.html\n" |
| 117 | "# This file was generated by cocos2d-x! Edit at your own risk.\n" |
| 118 | "# Test cocos2d-x cookie write.\n\n", |
| 119 | out); |
| 120 | |
| 121 | ccstd::string line; |
| 122 | for (auto &cookie : _cookies) { |
| 123 | line.clear(); |
| 124 | line.append(cookie.domain); |
| 125 | line.append(1, '\t'); |
| 126 | cookie.tailmatch ? line.append("TRUE") : line.append("FALSE"); |
| 127 | line.append(1, '\t'); |
| 128 | line.append(cookie.path); |
| 129 | line.append(1, '\t'); |
| 130 | cookie.secure ? line.append("TRUE") : line.append("FALSE"); |
| 131 | line.append(1, '\t'); |
| 132 | line.append(cookie.expires); |
| 133 | line.append(1, '\t'); |
| 134 | line.append(cookie.name); |
| 135 | line.append(1, '\t'); |
| 136 | line.append(cookie.value); |
| 137 | //line.append(1, '\n'); |
| 138 | |
| 139 | fprintf(out, "%s\n", line.c_str()); |
| 140 | } |
| 141 | |
| 142 | fclose(out); |
| 143 | } |
| 144 | |
| 145 | void HttpCookie::setCookieFileName(const ccstd::string &filename) { |
| 146 | _cookieFileName = filename; |
no test coverage detected