Skip to content

Commit

Permalink
No User-Agent attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
OFFTKP committed Dec 23, 2023
1 parent e2d2a6e commit 83a1dd6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(ENABLE_RETRO_ACHIEVEMENTS "Enable Retro Achievements" ON)

if (EMSCRIPTEN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DSE_PLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DSE_PLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 ")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DSE_PLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 -s ASSERTIONS=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ELIMINATE\_DUPLICATE\_FUNCTIONS=1 -s ENVIRONMENT=web -s ASSERTIONS=0 -s WASM=1 -DSE_PLATFORM_WEB --shell-file ${PROJECT_SOURCE_DIR}/src/shell.html -s USE_CLOSURE_COMPILER=0 -s ASSERTIONS=1")
endif ()
if (MSVC)
# Perform extremely aggressive optimization on Release builds:
Expand Down
11 changes: 10 additions & 1 deletion src/retro_achievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ static void server_callback(const rc_api_request_t* request,
} else {
type = http_request_e::POST;
}
url += "?" + post_data;

printf("[rcheevos]: %s %s\n", url.c_str(), content_type.c_str());

#ifndef EMSCRIPTEN
std::thread thread([type, url, post_data, callback, callback_data](){
#endif
https_request(type, url, post_data, { {"User-Agent", "SkyEmu/4.0"} }, [callback, callback_data](const std::vector<uint8_t>& result) {
std::vector<std::pair<std::string, std::string>> headers;
#ifndef EMSCRIPTEN
// TODO(paris): When setting User-Agent from browser side, it sends a CORS preflight request
// which is makes the request fail.
headers.push_back({"User-Agent", "SkyEmu/4.0"});
#endif
https_request(type, url, {}, headers, [callback, callback_data](const std::vector<uint8_t>& result) {
if (result.empty())
{
printf("[rcheevos]: empty response\n");
Expand Down

0 comments on commit 83a1dd6

Please sign in to comment.