Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use invariant culture for uppercase & lowercase #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zelakus
Copy link

@zelakus zelakus commented Dec 5, 2023

Objective

Fixing invalid characters in web request headers on Turkish OS display language.

InvalidOperationException: Header value contains invalid characters
UnityEngine.Networking.UnityWebRequest.SetRequestHeader (System.String name, System.String value) (at <63fb9d7bd92242a7b4218da88657af33>:0)
Xsolla.Core.WebRequestHelper.AttachHeadersToRequest (UnityEngine.Networking.UnityWebRequest webRequest, System.Collections.Generic.List`1[T] requestHeaders) (at Assets/Xsolla/Core/WebRequests/WebRequestHelper.cs:117)
Xsolla.Core.WebRequestHelper.AttachHeadersToPostRequest (UnityEngine.Networking.UnityWebRequest webRequest, System.Collections.Generic.List`1[T] requestHeaders, System.Boolean withContentType) (at Assets/Xsolla/Core/WebRequests/WebRequestHelper.POST.cs:285)
Xsolla.Core.WebRequestHelper.PreparePostWebRequest (System.String url, System.Object jsonObject, System.Collections.Generic.List`1[T] requestHeaders) (at Assets/Xsolla/Core/WebRequests/WebRequestHelper.POST.cs:247)
Xsolla.Core.WebRequestHelper+<PostRequestCor>d__62`1[T].MoveNext () (at Assets/Xsolla/Core/WebRequests/WebRequestHelper.POST.cs:194)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <56073df97ede4f769c2cc45d546d986d>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
Xsolla.Core.WebRequestHelper:PostRequest(SdkType, String, SignInRequest, Action`1, Action`1, ErrorGroup) (at Assets/Xsolla/Core/WebRequests/WebRequestHelper.POST.cs:34)
Xsolla.Auth.XsollaAuth:SignIn(String, String, Action, Action`1, String) (at Assets/Xsolla/Auth/XsollaAuth.cs:110)

In this example stack trace was caused by the classic auth, but anything using Xsolla.Core.WebRequestHelper.GetUnityParameters has the same issue.

Cause

Xsolla Analytics is providing uppercase headers using OS Locale, turning X-BUILD-PLATFORM header's StandaloneWindows64 into STANDALONEWİNDOWS64 when display language of the OS is Turkish. As this uppercase İ is not a valid English character, the above exception was thrown.

Resolution

Turning upper and lower options into Invariant Culture fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant