MCPcopy Create free account
hub / github.com/SpartanJ/eepp / downloadAsyncRequest

Method downloadAsyncRequest

src/eepp/network/http.cpp:1475–1518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1473}
1474
1475Uint64 Http::downloadAsyncRequest( const Http::AsyncResponseCallback& cb,
1476 const Http::Request& request, IOStream& writeTo, Time timeout ) {
1477 Uint64 id = Http::AsyncRequest::IdCounter.fetch_add( 1, std::memory_order_relaxed );
1478#if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN
1479 WGetAsyncRequest* wget = new WGetAsyncRequest();
1480 wget->http = this;
1481 wget->cb = cb;
1482 wget->writeTo = &writeTo;
1483 wget->request = Http::Request( request );
1484 emscripten_async_wget2_data( ( getURI().toString() + request.getUri() ).c_str(),
1485 Request::methodToString( request.getMethod() ).c_str(),
1486 URI( request.getUri() ).getQuery().c_str(), wget, 1,
1487 emscripten_async_wget2_got_data,
1488 emscripten_async_wget2_got_error_data, NULL );
1489 return id;
1490#else
1491 if ( sGlobalThreadPool ) {
1492 sGlobalThreadPool->run( [this, cb, request, &writeTo, timeout, id] {
1493 AsyncRequest asyncRequest( id, this, cb, request, writeTo, timeout, false );
1494 {
1495 Lock l( mCurRequestsMutex );
1496 mCurRequests[id] = &asyncRequest;
1497 }
1498 asyncRequest.run();
1499 {
1500 Lock l( mCurRequestsMutex );
1501 mCurRequests.erase( id );
1502 }
1503 } );
1504 return id;
1505 }
1506 AsyncRequest* thread = eeNew( AsyncRequest, ( id, this, cb, request, writeTo, timeout, true ) );
1507 {
1508 Lock l( mCurRequestsMutex );
1509 mCurRequests[id] = thread;
1510 }
1511 thread->launch();
1512 {
1513 Lock l( mThreadsMutex );
1514 mThreads.push_back( thread );
1515 }
1516 return id;
1517#endif
1518}
1519
1520Uint64 Http::downloadAsyncRequest( const Http::AsyncResponseCallback& cb,
1521 const Http::Request& request, std::string writePath,

Callers 1

requestAsyncMethod · 0.80

Calls 8

RequestClass · 0.85
c_strMethod · 0.80
getQueryMethod · 0.80
launchMethod · 0.80
push_backMethod · 0.80
toStringMethod · 0.45
runMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected