mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Fix b5acd75c3e1dc8cbf9f9dc24388b25e3cff737c1 accidentally causing User Agent header to no longer include special platform names
This commit is contained in:
parent
ffee69ffa1
commit
4bf1fc4ac1
@ -121,6 +121,17 @@ static void Http_SetRequestHeaders(struct HttpRequest* req) {
|
|||||||
Http_AddHeader(req, "Cookie", &cookies);
|
Http_AddHeader(req, "Cookie", &cookies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Rewrite to use a local variable instead */
|
||||||
|
static cc_string* Http_GetUserAgent_UNSAFE(void) {
|
||||||
|
static char userAgentBuffer[STRING_SIZE];
|
||||||
|
static cc_string userAgent;
|
||||||
|
|
||||||
|
String_InitArray(userAgent, userAgentBuffer);
|
||||||
|
String_AppendConst(&userAgent, GAME_APP_NAME);
|
||||||
|
String_AppendConst(&userAgent, Platform_AppNameSuffix);
|
||||||
|
return &userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
static void Http_SignalWorker(void) { Waitable_Signal(workerWaitable); }
|
static void Http_SignalWorker(void) { Waitable_Signal(workerWaitable); }
|
||||||
|
|
||||||
/* Adds a req to the list of pending requests, waking up worker thread if needed */
|
/* Adds a req to the list of pending requests, waking up worker thread if needed */
|
||||||
@ -634,8 +645,7 @@ static void HttpClientState_Init(struct HttpClientState* state) {
|
|||||||
|
|
||||||
|
|
||||||
static void HttpClient_Serialise(struct HttpClientState* state) {
|
static void HttpClient_Serialise(struct HttpClientState* state) {
|
||||||
static const cc_string userAgent = String_FromConst(GAME_APP_NAME);
|
static const char* verbs[] = { "GET", "HEAD", "POST" };
|
||||||
static const char* verbs[3] = { "GET", "HEAD", "POST" };
|
|
||||||
|
|
||||||
struct HttpRequest* req = state->req;
|
struct HttpRequest* req = state->req;
|
||||||
cc_string* buffer = (cc_string*)req->meta;
|
cc_string* buffer = (cc_string*)req->meta;
|
||||||
@ -645,7 +655,7 @@ static void HttpClient_Serialise(struct HttpClientState* state) {
|
|||||||
verbs[req->requestType], &state->url.resource);
|
verbs[req->requestType], &state->url.resource);
|
||||||
|
|
||||||
Http_AddHeader(req, "Host", &state->url.address);
|
Http_AddHeader(req, "Host", &state->url.address);
|
||||||
Http_AddHeader(req, "User-Agent", &userAgent);
|
Http_AddHeader(req, "User-Agent", Http_GetUserAgent_UNSAFE());
|
||||||
if (req->data) String_Format1(buffer, "Content-Length: %i\r\n", &req->size);
|
if (req->data) String_Format1(buffer, "Content-Length: %i\r\n", &req->size);
|
||||||
|
|
||||||
Http_SetRequestHeaders(req);
|
Http_SetRequestHeaders(req);
|
||||||
@ -1306,7 +1316,6 @@ static cc_result Http_SetData(JNIEnv* env, struct HttpRequest* req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) {
|
static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) {
|
||||||
static const cc_string userAgent = String_FromConst(GAME_APP_NAME);
|
|
||||||
JNIEnv* env;
|
JNIEnv* env;
|
||||||
jint res;
|
jint res;
|
||||||
|
|
||||||
@ -1315,7 +1324,7 @@ static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) {
|
|||||||
java_req = req;
|
java_req = req;
|
||||||
|
|
||||||
Http_SetRequestHeaders(req);
|
Http_SetRequestHeaders(req);
|
||||||
Http_AddHeader(req, "User-Agent", &userAgent);
|
Http_AddHeader(req, "User-Agent", Http_GetUserAgent_UNSAFE());
|
||||||
if (req->data && (res = Http_SetData(env, req))) return res;
|
if (req->data && (res = Http_SetData(env, req))) return res;
|
||||||
|
|
||||||
req->_capacity = 0;
|
req->_capacity = 0;
|
||||||
@ -1381,7 +1390,6 @@ static cc_result ParseResponseHeaders(struct HttpRequest* req, CFReadStreamRef s
|
|||||||
}
|
}
|
||||||
|
|
||||||
static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) {
|
static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) {
|
||||||
static const cc_string userAgent = String_FromConst(GAME_APP_NAME);
|
|
||||||
static CFStringRef verbs[] = { CFSTR("GET"), CFSTR("HEAD"), CFSTR("POST") };
|
static CFStringRef verbs[] = { CFSTR("GET"), CFSTR("HEAD"), CFSTR("POST") };
|
||||||
cc_bool gotHeaders = false;
|
cc_bool gotHeaders = false;
|
||||||
char tmp[NATIVE_STR_LEN];
|
char tmp[NATIVE_STR_LEN];
|
||||||
@ -1400,7 +1408,7 @@ static cc_result HttpBackend_Do(struct HttpRequest* req, cc_string* url) {
|
|||||||
request = CFHTTPMessageCreateRequest(NULL, verbs[req->requestType], urlRef, kCFHTTPVersion1_1);
|
request = CFHTTPMessageCreateRequest(NULL, verbs[req->requestType], urlRef, kCFHTTPVersion1_1);
|
||||||
req->meta = request;
|
req->meta = request;
|
||||||
Http_SetRequestHeaders(req);
|
Http_SetRequestHeaders(req);
|
||||||
Http_AddHeader(req, "User-Agent", &userAgent);
|
Http_AddHeader(req, "User-Agent", Http_GetUserAgent_UNSAFE());
|
||||||
CFRelease(urlRef);
|
CFRelease(urlRef);
|
||||||
|
|
||||||
if (req->data && req->size) {
|
if (req->data && req->size) {
|
||||||
|
@ -76,9 +76,9 @@ static int RunProgram(int argc, char** argv) {
|
|||||||
int argsCount = Platform_GetCommandLineArgs(argc, argv, args);
|
int argsCount = Platform_GetCommandLineArgs(argc, argv, args);
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
/* NOTE: Make sure to comment this out before pushing a commit */
|
/* NOTE: Make sure to comment this out before pushing a commit */
|
||||||
//cc_string rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565");
|
cc_string rawArgs = String_FromConst("UnknownShadow200 fffff 127.0.0.1 25565");
|
||||||
//cc_string rawArgs = String_FromConst("UnknownShadow200");
|
//cc_string rawArgs = String_FromConst("UnknownShadow200");
|
||||||
//argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4);
|
argsCount = String_UNSAFE_Split(&rawArgs, ' ', args, 4);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (argsCount == 0) {
|
if (argsCount == 0) {
|
||||||
|
@ -73,7 +73,7 @@ static struct CpeExt
|
|||||||
blockDefsExt_Ext = { "BlockDefinitionsExt", 2 },
|
blockDefsExt_Ext = { "BlockDefinitionsExt", 2 },
|
||||||
bulkBlockUpdate_Ext = { "BulkBlockUpdate", 1 },
|
bulkBlockUpdate_Ext = { "BulkBlockUpdate", 1 },
|
||||||
textColors_Ext = { "TextColors", 1 },
|
textColors_Ext = { "TextColors", 1 },
|
||||||
envMapAspect_Ext = { "EnvMapAspect", 1 },
|
envMapAspect_Ext = { "EnvMapAspect", 2 },
|
||||||
entityProperty_Ext = { "EntityProperty", 1 },
|
entityProperty_Ext = { "EntityProperty", 1 },
|
||||||
extEntityPos_Ext = { "ExtEntityPositions", 1 },
|
extEntityPos_Ext = { "ExtEntityPositions", 1 },
|
||||||
twoWayPing_Ext = { "TwoWayPing", 1 },
|
twoWayPing_Ext = { "TwoWayPing", 1 },
|
||||||
@ -819,7 +819,6 @@ static cc_uint8* Classic_Tick(cc_uint8* data) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------CPE protocol-------------------------------------------------------*
|
*------------------------------------------------------CPE protocol-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
|
||||||
static void CPEExtensions_Reset(void) {
|
static void CPEExtensions_Reset(void) {
|
||||||
struct CpeExt* ext;
|
struct CpeExt* ext;
|
||||||
int i;
|
int i;
|
||||||
@ -842,7 +841,6 @@ static struct CpeExt* CPEExtensions_Find(const cc_string* name) {
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static void CPE_SetMapEnvUrl(cc_uint8* data);
|
|
||||||
|
|
||||||
#define Ext_Deg2Packed(x) ((int)((x) * 65536.0f / 360.0f))
|
#define Ext_Deg2Packed(x) ((int)((x) * 65536.0f / 360.0f))
|
||||||
void CPE_SendPlayerClick(int button, cc_bool pressed, cc_uint8 targetId, struct RayTracer* t) {
|
void CPE_SendPlayerClick(int button, cc_bool pressed, cc_uint8 targetId, struct RayTracer* t) {
|
||||||
@ -1025,6 +1023,14 @@ static void CPE_ExtEntry(cc_uint8* data) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CPE_ApplyTexturePack(const cc_string* url) {
|
||||||
|
if (!url->length || Utils_IsUrlPrefix(url)) {
|
||||||
|
Server_RetrieveTexturePack(url);
|
||||||
|
}
|
||||||
|
Platform_Log1("Tex url: %s", url);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void CPE_SetClickDistance(cc_uint8* data) {
|
static void CPE_SetClickDistance(cc_uint8* data) {
|
||||||
LocalPlayer_Instance.ReachDistance = Stream_GetU16_BE(data) / 32.0f;
|
LocalPlayer_Instance.ReachDistance = Stream_GetU16_BE(data) / 32.0f;
|
||||||
}
|
}
|
||||||
@ -1173,9 +1179,10 @@ static void CPE_ChangeModel(cc_uint8* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void CPE_EnvSetMapAppearance(cc_uint8* data) {
|
static void CPE_EnvSetMapAppearance(cc_uint8* data) {
|
||||||
|
cc_string url = UNSAFE_GetString(data);
|
||||||
int maxViewDist;
|
int maxViewDist;
|
||||||
|
CPE_ApplyTexturePack(&url);
|
||||||
|
|
||||||
CPE_SetMapEnvUrl(data);
|
|
||||||
Env_SetSidesBlock(data[64]);
|
Env_SetSidesBlock(data[64]);
|
||||||
Env_SetEdgeBlock(data[65]);
|
Env_SetEdgeBlock(data[65]);
|
||||||
Env_SetEdgeHeight((cc_int16)Stream_GetU16_BE(data + 66));
|
Env_SetEdgeHeight((cc_int16)Stream_GetU16_BE(data + 66));
|
||||||
@ -1280,11 +1287,7 @@ static void CPE_SetTextColor(cc_uint8* data) {
|
|||||||
|
|
||||||
static void CPE_SetMapEnvUrl(cc_uint8* data) {
|
static void CPE_SetMapEnvUrl(cc_uint8* data) {
|
||||||
cc_string url = UNSAFE_GetString(data);
|
cc_string url = UNSAFE_GetString(data);
|
||||||
|
CPE_ApplyTexturePack(&url);
|
||||||
if (!url.length || Utils_IsUrlPrefix(&url)) {
|
|
||||||
Server_RetrieveTexturePack(&url);
|
|
||||||
}
|
|
||||||
Platform_Log1("Tex url: %s", &url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CPE_SetMapEnvProperty(cc_uint8* data) {
|
static void CPE_SetMapEnvProperty(cc_uint8* data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user