-
Notifications
You must be signed in to change notification settings - Fork 519
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
HttpClient and AcceptEncoding gzip on Android stoped working after latest SR4 release. #8928
Comments
Issue moved from dotnet/maui#21786
From @PureWeen on Thursday, April 11, 2024 10:18:56 PM @jonathanpeppers thoughts? |
Issue moved from dotnet/maui#21786
From @jonathanpeppers on Friday, April 12, 2024 2:15:19 AM @JoacimWall can you share more complete sample code? You might be able to test with: https://httpbin.org/ @simonrozsival @grendello could this be related to some of the changes here: |
Issue moved from dotnet/maui#21786
From @JoacimWall on Friday, April 12, 2024 6:25:07 AM
Hi I have now published a dummy API on Azure (the code is in the repo also). |
Issue moved from dotnet/maui#21786
From @simonrozsival on Friday, April 12, 2024 7:27:32 AM @jonathanpeppers @grendello This change is probably relevant: #8753 @JoacimWall could you please try setting |
Issue moved from dotnet/maui#21786
From @jonathanpeppers on Friday, April 12, 2024 1:40:41 PM It seems like the BCL doesn't have automatic decompression by default:
So, was It does seem like we should match BCL behavior, just unfortunate it changed in a service release. |
Issue moved from dotnet/maui#21786
From @JoacimWall on Thursday, May 2, 2024 5:53:32 AM Hello //Regards Joacim |
Issue moved from dotnet/maui#21786
From @simonrozsival on Thursday, May 2, 2024 8:45:08 AM @JoacimWall I noticed that in the
When I change the default I'm slightly confused that you report that this used to work on Android in MAUI 8.0.6. I thought I might have broken the default behavior in #8753 but after revisiting it, I can't find a way that this could have been affected. |
Issue moved from dotnet/maui#21786
From @JoacimWall on Thursday, May 2, 2024 9:42:24 AM
Hi I spent some hours to find what it was that generate the error create I sample and report this issue. So others could skip spending the hours to find the root issue. //Joacim |
Issue moved from dotnet/maui#21786
From @simonrozsival on Thursday, May 2, 2024 12:58:27 PM @JoacimWall thanks for the additional details. @grendello do you have an idea if we could have broken this with #8753 or what else could have caused this regression? |
@PureWeen yes, I think the change might have broken the sample code. In particular, this line might be overriding the headers, if the |
@grendello I'm having problems reproducing the original working solution. I'm not getting any automatic decompression when I set just the default headers. The |
I had the exact same problem, http response was just gibberish. Had to roll VS back to previous version which fixed it. |
I also have the same problem. My code is from a old XF App, which i triy to migrate. This: var handler = new HttpClientHandler {
AutomaticDecompression = DecompressionMethods.GZip,
};
var client = new HttpClient(handler); This handler add the AcceptEncoding Header for outgoing requests? Thank you |
@AlleSchonWeg yes, this is the preferred way. The handler will automatically add the appropriate encoding headers and if the server responds with compressed data, it will automatically decompress it. |
@simonrozsival Thank you. var response = client .GetAsync("https://httpbingo.org/headers").Result;
var resultString = client.Content.ReadAsStringAsync().Result; This was the reponse: {
"headers": {
"Accept": [
"application/json"
],
"Accept-Encoding": [
"gzip"
],
"Accept-Language": [
"en"
],
"Host": [
"httpbingo.org"
],
"User-Agent": [
"XXX0 (DEV; Phone; Google; sdk_gphone64_x86_64; Android 14)"
],
"Via": [
"1.1 fly.io"
],
"X-Forwarded-For": [
"YYY, ZZZ"
],
"X-Forwarded-Port": [
"443"
],
"X-Forwarded-Proto": [
"https"
],
"X-Forwarded-Ssl": [
"on"
],
"X-Request-Start": [
"t=1716456090916385"
]
}
} The Accept-Encoding was successfully set. Can't test iOS. |
@grendello @PureWeen I have tried again and I wasn't able to get the original described behavior to work. I'm not sure what caused this problem and how to fix it. Moreover, I'm not sure if we want to even support this behavior of enabling automatic decompression by setting the |
@simonrozsival I looked at it a bit too and I have absolutely no clue why it worked before and stopped now. Clearly, it's some change in the http handler inheritance tree or thereabouts, but I think I agree with you that the way to do it by setting the property is the correct one. Especially that we're dealing with a "proxy" handler in this case, and most of the magic somehow happens in the Java backend we have no control over. As far as I can tell, we did nothing special before to make the scenario work, so I wouldn't exclude the possibility that the behavior might be different also because of a different target SDK when the app is built. All in all, I'm in favor of documenting the issue and specifying what is the correct and supported way to achieve the desired outcome. |
Issue moved from dotnet/maui#21786
From @JoacimWall on Thursday, April 11, 2024 6:58:03 PM
Description
After I updated to latest Dotnet SDK and workloads on my dev machine my app start to return error on some API calls. The same thing happened in Azure Pipeline even though I didn't make any changes to the script.
The app works flawlessly under Ios.
So the unchanged code that target MAUI 8.0.6( Also tested target 8.0.20) return the same error.
if I just check de content of the return it's still gzip I think.
var test = result.Content.ReadAsStringAsync()
on Ios = "{"authentication":{"logintoken":
on Android = "��\b\0\0\0\0\0�\0��n�8��_�0��g�T������-ǒc[�,-��)Q�e�"ɲ�A�f�a_`^l)'��N����3h����!�(�>�������UHҊz��Y�y�s'�
//Joacim
Steps to Reproduce
If I check the logs of the Mac build host in Azure pipeline
Pool: Azure Pipelines
Image: macOS-13
Agent: Azure Pipelines 3
Started: Today at 20:01
Duration: 10m 39s
I see that
Successfully installed .NET Core sdk version 8.0.201.
Creating global tool path and pre-pending to PATH.
Finishing: Use .Net 8
and the
dotnet workload install maui
Now installs newer versions of the workload and other parts than it did before, Maybe the error is there somewhere
Link to public reproduction project repository
https://github.com/JoacimWall/Joacim_Bug_Report/tree/main/GzipBug
Version with bug
8.0.20 SR4
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.6 SR1
Affected platforms
Android
Affected platform versions
No response
Did you find any workaround?
Yes
turn of the gzip for Android
#if IOS
this.client.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
#endif
Relevant log output
The text was updated successfully, but these errors were encountered: