* Effectue la requete */
| 224 | * Effectue la requete |
| 225 | */ |
| 226 | void http::runRequest(const char* page, int async) { |
| 227 | _page = page; |
| 228 | _status = ST_PENDING; |
| 229 | _async = (AsyncMode)async; |
| 230 | _progressValue = 0; |
| 231 | |
| 232 | std::string url = cross_domain; |
| 233 | url += _hostname + _page; |
| 234 | |
| 235 | if (_hostname.size() > 0 && _page.size() > 0) { |
| 236 | |
| 237 | printf("URL : %s\n",url.c_str()); |
| 238 | printf("REQUEST : %s\n", _request == REQUEST_GET ? "GET" : "POST"); |
| 239 | printf("PARAMS : %s\n",_param.c_str()); |
| 240 | |
| 241 | if (_targetFileName.size() == 0 ) { |
| 242 | _targetFileName = format("prepare%d",_uid); |
| 243 | } |
| 244 | |
| 245 | _handle = emscripten_async_wget2(url.c_str(), _targetFileName.c_str(), _request == REQUEST_GET ? "GET" : "POST", _param.c_str(), this, http::onLoaded, http::onError, http::onProgress); |
| 246 | |
| 247 | } else { |
| 248 | _error = format("malformed url : %s\n",url.c_str()); |
| 249 | _content = ""; |
| 250 | _status = ST_FAILED; |
| 251 | _progressValue = -1; |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * Post |