-
-
Notifications
You must be signed in to change notification settings - Fork 207
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
Add support for compressed requests, such as GZIP or DEFLATE #426
Comments
So an issue which we were having was resolved when we stopped sending it GZIP'd, so I guess that is the answer. Can we add support for GZIP/Deflate to the server? |
|
I took a swing at it and created #430. I decided to let CI build it for me. Let's see what we get. |
So I tried this in #430 ... The issue that I ran into has to do with framework version compatibility. I have the more or less correct approach, but it needs a little dedicated hand holding. |
I think it's easier to just view the I'll take a look. |
@ezarko Can you try preview version on MyGet : |
@ezarko Did you have time to test this new version? |
@ezarko Can you please test if this works for you? |
1 similar comment
@ezarko Can you please test if this works for you? |
Hello @ezarko , did you have time yet to test this ? |
@StefH sorry for taking so long to get back to you. If you can provide a Docker image, or give me instructions on how to build one myself using the preview version, I can get this tested next week. Alternatively I can see about creating a test for it, if that helps. It should be as simple as: echo ‘{“foo”:”bar”}’ | gzip -c | curl -H’Content-Type: application/json’ -H’Content-Encoding: Gzip’ --data-binary @- Or you could prepare a gzip-ed file and put it in a test class as an array of bytes or whatever. |
I've already build a test like this: [Theory]
[InlineData("gzip")]
[InlineData("deflate")]
public async Task WireMockServer_Should_SupportRequestGZipAndDeflate(string contentEncoding)
{
// Arrange
const string body = "hello wiremock";
byte[] compressed = CompressionUtils.Compress(contentEncoding, Encoding.UTF8.GetBytes(body));
var server = WireMockServer.Start();
server.Given(
Request.Create()
.WithPath("/foo")
.WithBody("hello wiremock")
)
.RespondWith(
Response.Create().WithBody("OK")
);
var content = new StreamContent(new MemoryStream(compressed));
content.Headers.ContentType = new MediaTypeHeaderValue("text/plain");
content.Headers.ContentEncoding.Add(contentEncoding);
// Act
var response = await new HttpClient().PostAsync($"{server.Urls[0]}/foo", content);
// Assert
Check.That(await response.Content.ReadAsStringAsync()).Contains("OK");
} So I think we are good to go. I will merge the PR and create a new Docker image this weekend and close this PR. Just test it when you have time, and if you still find an problem, just create an issue. |
I did a quick search in the code and see an HttpClient with these settings, but I am assuming that is used by the proxy. Can the server itself handle an incoming request with has been GZIP'd?
The text was updated successfully, but these errors were encountered: