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
POST request with GZIPPED json not working with request.AddJsonBody #1438
Comments
RestSharp wasn't designed to compress the payload. So, it is not a bug and there's no word in the docs that give a clue that it would compress the payload based on the content type set in the header. It can be done very easily by creating a custom serializer https://restsharp.dev/usage/serialization.html#custom So, I can mark it up for grabs, if you are willing to contribute. |
Thank you for quick response! Ah me not reading & interpreting the docs oke: Sorry. Can try to make a PR for this with a GZipSerializer that can be decorated with an JSonSerializer. For the time being as an optional class to be set if wanted? |
Looked at the code and found out that its not a trivial task to introduce Compression using the IRestSerializer/ISerializer/IDeserializer interface(s). byte[] Serialize(object payload); // in stead of string.
// or
void Serialize(Stream stream); Or introduce a new Interface for e.g. "RestSharp.Sinks" with an Interface that supports Stream and/or byte[]. So extend existing Interfaces or add a new one? Kind regards |
I would prefer that serializers will use byte arrays but it will be a breaking change, so I'll have to merge it after the last minor release of v106 so we can take it in to v107. |
Oke I will give it a go. Thanks for replying quickly! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Expected Behavior
GZIP Compression with POST working in combination with request.AddJsonBody.
Actual Behavior
Get a Gateway timeout when using request.AddJsonBody in combination with Content-Encoding: gzip.
Works when I gzip the serialized json myself and post it. (See beneath code).
Steps to Reproduce the Problem
This code is working:
Fiddler's raw request header:
and raw response header:
This code is NOT working:
Fiddler's raw request header:
Raw response header:
Specifications
The text was updated successfully, but these errors were encountered: