mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-28 11:24:15 +08:00
workaround a problem in Steam_HTTP::SetHTTPRequestHeaderValue()
where some games set a cache-control policy which allows only reponses from previous requests
This commit is contained in:
parent
d7fb8403d1
commit
afee4c4a72
@ -30,12 +30,15 @@ struct Steam_Http_Request {
|
||||
bool requires_valid_ssl = false;
|
||||
|
||||
constexpr const static char STEAM_DEFAULT_USER_AGENT[] = "Valve/Steam HTTP Client 1.0";
|
||||
// GET or POST parameter value on the request
|
||||
// check Steam_HTTP::SetHTTPRequestHeaderValue() and make sure to bypass the ones that should be reserved
|
||||
std::map<std::string, std::string> headers{
|
||||
{"User-Agent", STEAM_DEFAULT_USER_AGENT},
|
||||
{ "User-Agent", STEAM_DEFAULT_USER_AGENT },
|
||||
{ "Cache-Control", "max-age=0" },
|
||||
{ "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" },
|
||||
{ "Upgrade-Insecure-Requests", "1" },
|
||||
};
|
||||
|
||||
// GET or POST parameter value on the request
|
||||
// GET or POST parameter value of the request
|
||||
std::map<std::string, std::string> get_or_post_params{};
|
||||
std::string post_raw{};
|
||||
|
||||
|
@ -38,7 +38,7 @@ Steam_Http_Request *Steam_HTTP::get_request(HTTPRequestHandle hRequest)
|
||||
// or such.
|
||||
HTTPRequestHandle Steam_HTTP::CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod, const char *pchAbsoluteURL )
|
||||
{
|
||||
PRINT_DEBUG("%i %s", eHTTPRequestMethod, pchAbsoluteURL);
|
||||
PRINT_DEBUG("%i '%s'", eHTTPRequestMethod, pchAbsoluteURL);
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
|
||||
if (!pchAbsoluteURL) return INVALID_HTTPREQUEST_HANDLE;
|
||||
@ -83,7 +83,7 @@ HTTPRequestHandle Steam_HTTP::CreateHTTPRequest( EHTTPMethod eHTTPRequestMethod,
|
||||
// sending the request. This is just so the caller can easily keep track of which callbacks go with which request data.
|
||||
bool Steam_HTTP::SetHTTPRequestContextValue( HTTPRequestHandle hRequest, uint64 ulContextValue )
|
||||
{
|
||||
PRINT_DEBUG_ENTRY();
|
||||
PRINT_DEBUG("%llu", ulContextValue);
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
|
||||
Steam_Http_Request *request = get_request(hRequest);
|
||||
@ -122,15 +122,19 @@ bool Steam_HTTP::SetHTTPRequestHeaderValue( HTTPRequestHandle hRequest, const ch
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
|
||||
if (!pchHeaderName || !pchHeaderValue) return false;
|
||||
std::string headerName(pchHeaderName);
|
||||
std::transform(headerName.begin(), headerName.end(), headerName.begin(), [](char c){ return (char)std::toupper(c); });
|
||||
if (headerName == "USER-AGENT") return false;
|
||||
if (common_helpers::str_cmp_insensitive(pchHeaderName, "User-Agent")) return false;
|
||||
|
||||
Steam_Http_Request *request = get_request(hRequest);
|
||||
if (!request) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIX: appid 1902490 adds the header "Cache-Control: only-if-cached, max-stale=2678400"
|
||||
// which means a response is returned back only if it was already cached, otherwise the server has to send a 504 "Gateway Timeout"
|
||||
// just bypass the known ones to be on the safe side
|
||||
if (common_helpers::str_cmp_insensitive(pchHeaderName, "Cache-Control")) return true;
|
||||
if (common_helpers::str_cmp_insensitive(pchHeaderName, "Accept")) return true;
|
||||
|
||||
request->headers[pchHeaderName] = pchHeaderValue;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user