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

Header not being returned when set in WithCallback #602

Closed
GrantGHub opened this issue Apr 15, 2021 · 3 comments
Closed

Header not being returned when set in WithCallback #602

GrantGHub opened this issue Apr 15, 2021 · 3 comments
Assignees
Labels

Comments

@GrantGHub
Copy link

GrantGHub commented Apr 15, 2021

Upgraded from 1.2.14 to 1.4.9. Was setting the header in WithCallback. This was correctly coming through. Now no headers are returned.

Taking the example tests and adjusting it (removing .WithHeader(header, "Stef");), should return the header set within WithCallback:

        public async Task Response_WithCallback_And_WithStatusCode_And_WithHeader()
        {
            // Assign
            var header = "X-UserId";
            var requestMessage = new RequestMessage(new UrlDetails("http:https://localhost/foo"), "GET", "::1");
            var responseBuilder = Response.Create()
                .WithCallback(request => new ResponseMessage
                {
                    BodyData = new BodyData
                    {
                        DetectedBodyType = BodyType.String,
                        BodyAsString = request.Path + "Bar"
                    },
                    StatusCode = HttpStatusCode.Accepted,
                    Headers = new Dictionary<string, WireMockList<string>>
                    {
                        { header, new WireMockList<string>("NA") }
                    }
                });

            // Act
            var response = await responseBuilder.ProvideResponseAsync(requestMessage, _settings);

            // Assert
            response.Message.BodyData.BodyAsString.Should().Be("/fooBar");
            response.Message.StatusCode.Should().Be(HttpStatusCode.Accepted);
            response.Message.Headers[header].Should().ContainSingle("NA");
        }

Headers are coming back empty.

response.Message.Headers.Count == 0
true

@GrantGHub GrantGHub added the bug label Apr 15, 2021
@StefH
Copy link
Collaborator

StefH commented Apr 15, 2021

@GrantGHub Thanks for finding this.

@StefH StefH self-assigned this Apr 15, 2021
@StefH
Copy link
Collaborator

StefH commented Apr 15, 2021

#603

New version will be released shorty.

@StefH StefH closed this as completed Apr 15, 2021
@GrantGHub
Copy link
Author

Thank you for such a fast turn around. I have retrieved the latest and confirm the issue has been resolved.

Thanks again for the responsiveness to this request. Appreciate it.

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

No branches or pull requests

2 participants