diff --git a/src/jni/lib_http_client.cpp b/src/jni/lib_http_client.cpp index 6c1512a8..a7edbcb2 100644 --- a/src/jni/lib_http_client.cpp +++ b/src/jni/lib_http_client.cpp @@ -3,6 +3,9 @@ #include #include #include +#ifndef HTTPCLIENT_NDEBUG +#include +#endif using namespace std::placeholders; @@ -29,7 +32,8 @@ std::shared_ptr HttpClientRequest::createClientRequest() { } void HttpClientRequest::setHttpUrl(std::shared_ptr url) { -#ifndef NDEBUG +#ifndef HTTPCLIENT_NDEBUG + this->url = url->asStdString(); Log::trace("HttpClient", "URL: %s", url->asStdString().c_str()); #endif curl_easy_setopt(curl, CURLOPT_URL, url->asStdString().c_str()); @@ -64,7 +68,9 @@ void HttpClientRequest::setHttpMethodAndBody(std::shared_ptr m static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userdata) { auto stream = (NativeInputStream *)userdata; try { - return stream->Read(ptr, size * nmemb); + auto ret = stream->Read(ptr, size * nmemb); + std::cout << "HTTPContent:\n" << std::string_view(ptr, ret) << "\n"; + return ret; } catch(...) { #ifdef CURL_READFUNC_ABORT return CURL_READFUNC_ABORT; @@ -98,7 +104,7 @@ void HttpClientRequest::setHttpMethodAndBody2(std::shared_ptr } else if (this->method == "PUT") { curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t) contentLength); } -#ifndef NDEBUG +#ifndef HTTPCLIENT_NDEBUG Log::trace("HttpClient", "setHttpMethodAndBody2 called, sent request"); #endif } else { @@ -106,7 +112,7 @@ void HttpClientRequest::setHttpMethodAndBody2(std::shared_ptr curl_easy_setopt(curl, CURLOPT_POSTFIELDS, ""); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0); } -#ifndef NDEBUG +#ifndef HTTPCLIENT_NDEBUG Log::trace("HttpClient", "setHttpMethodAndBody2 called, method: %s", this->method.c_str()); #endif } @@ -120,8 +126,11 @@ void HttpClientRequest::setHttpMethodAndBody2(std::shared_ptr } void HttpClientRequest::setHttpHeader(std::shared_ptr name, std::shared_ptr value) { -#ifndef NDEBUG - Log::trace("HttpClient", "setHttpHeader called, name: %s, value: %s", name->asStdString().c_str(), value->asStdString().c_str()); +#ifndef HTTPCLIENT_NDEBUG + Log::trace("HttpClient", "%s setHttpHeader called, name: %s, value: %s", url.data(), name->asStdString().c_str(), value->asStdString().c_str()); + if(name->asStdString() == "Authorization") { + Log::trace("HttpClient", "Auth"); + } #endif header = curl_slist_append(header, (name->asStdString() + ": " + value->asStdString()).c_str()); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header); @@ -141,7 +150,7 @@ void HttpClientRequest::doRequestAsync(FakeJni::JLong sourceCall) { curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &response_code); FakeJni::LocalFrame frame; if(ret == CURLE_OK) { -#ifndef NDEBUG +#ifndef HTTPCLIENT_NDEBUG Log::trace("HttpClient", "Response: code: %ld", response_code); #endif auto method = getClass().getMethod("(JLcom/xbox/httpclient/HttpClientResponse;)V", "OnRequestCompleted"); @@ -192,6 +201,9 @@ HttpClientResponse::HttpClientResponse(FakeJni::JLong call_handle, int response_ size_t HttpClientRequest::write_callback(char *ptr, size_t size, size_t nmemb) { try { +#ifndef HTTPCLIENT_NDEBUG + std::cout << "HTTPBody: " << url.data() << "\n" << std::string_view(ptr, size * nmemb) << "\n"; +#endif auto byteArray = std::make_shared(nmemb); memcpy(byteArray->getArray(), ptr, nmemb); std::make_shared(call_handle)->WriteAll(byteArray); diff --git a/src/jni/lib_http_client.h b/src/jni/lib_http_client.h index 74ec338c..63930c64 100644 --- a/src/jni/lib_http_client.h +++ b/src/jni/lib_http_client.h @@ -25,7 +25,7 @@ class NativeInputStream : public FakeJni::JObject { class HttpClientRequest : public FakeJni::JObject { std::shared_ptr inputStream; - + std::string url; public: DEFINE_CLASS_NAME("com/xbox/httpclient/HttpClientRequest") HttpClientRequest(); diff --git a/src/main.cpp b/src/main.cpp index 02352675..dda8546c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -328,6 +328,8 @@ Hardware : Qualcomm Technologies, Inc MSM8998 // GLFW needs a window to let eglGetProcAddress return symbols FakeLooper::initWindow(); MinecraftUtils::setupGLES2Symbols(fake_egl::eglGetProcAddress); + // preinit Mods using libGLESv2 can only load now + modLoader.loadModsFromDirectory(PathHelper::getPrimaryDataDirectory() + "mods/", true); // Try load the game again handle = MinecraftUtils::loadMinecraftLib(reinterpret_cast(&CorePatches::showMousePointer), reinterpret_cast(&CorePatches::hideMousePointer), reinterpret_cast(&CorePatches::setFullscreen)); }