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

Question: How to specify Transfer-Encoding response header? #137

Closed
o7g8 opened this issue May 16, 2018 · 4 comments
Closed

Question: How to specify Transfer-Encoding response header? #137

o7g8 opened this issue May 16, 2018 · 4 comments

Comments

@o7g8
Copy link

o7g8 commented May 16, 2018

Hello,

I need to specify my own Transfer-Encoding response header as it's shown in the example below:

        [TestMethod]
        public async Task CheckMockHeaders() {
            var responseBody = @"<?xml version=""1.0""?><empty/>";
            mockServer
                .Given(Request
                    .Create()
                    .WithPath("/test")
                    .UsingPost())
                .RespondWith(Response
                    .Create()
                    .WithStatusCode(200)
                    .WithHeader("content-type", "text/xml")
                    .WithHeader("Content-Length", responseBody.Length.ToString())
                    .WithHeader("Transfer-Encoding", "identity")
                    .WithBody(responseBody));
            using (var httpClient = new HttpClient()) {
                var uri = mockServer.Urls.Single() + "test";
                using (var response = await httpClient.PostAsync(uri, new StringContent(""))) {
                    response.EnsureSuccessStatusCode();
                    
                    var transferEncoding = response.Headers.SingleOrDefault(x => x.Key == "Transfer-Encoding");
                    Assert.IsNotNull(transferEncoding);
                    Assert.IsTrue(transferEncoding.Value.Contains("identity"));
                }
            }
        }

The last Assert fails, because the Transfer-Encoding is always chunked.
Is it possible to override it?

WireMock.Net version 1.0.3.16.

@StefH StefH changed the title [Q] How to specify Transfer-Encoding response header? Question: How to specify Transfer-Encoding response header? May 16, 2018
@StefH
Copy link
Collaborator

StefH commented May 16, 2018

Linked to #136

@StefH
Copy link
Collaborator

StefH commented May 25, 2018

Solved, see NuGet 1.0.3.18

@StefH StefH closed this as completed May 25, 2018
@GMPrakhar
Copy link

I am seeing this issue again.. Transfer-encoding always goes as chunked when used with WithBodyFromFile

@gorillapower
Copy link

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

No branches or pull requests

4 participants