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

Mock server unable to handle HEAD HTTP method #1828

Open
RanABI opened this issue Sep 24, 2024 · 1 comment
Open

Mock server unable to handle HEAD HTTP method #1828

RanABI opened this issue Sep 24, 2024 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@RanABI
Copy link

RanABI commented Sep 24, 2024

Hi team,
I am using your Mock-Servers,
When mocking an HTTP HEAD request, I receive the following error:

sun.net.httpserver.ExchangeImpl sendResponseHeaders

WARNING: sendResponseHeaders: being invoked with a content length for a HEAD request

2024-09-17 10:52:09,159 APP ERROR - [34][HTTP-Dispatcher] [] Failed to generate response

java.io.IOException: response headers not sent yet

at sun.net.httpserver.PlaceholderOutputStream.checkWrap(ExchangeImpl.java:448) ~[jdk.httpserver:?]

I see the error's origin is at MockHttpServer.kt , in the pactResponseToHttpExchange function, I guess the exchange is closing before response headers are being sent.

My mock is very simple -

builder.expectsToReceiveHttpInteraction("Auth check",
        interaction -> interaction
            .withRequest(request -> request
                .path("/v1/my/path")
                .method("HEAD")
            .willRespondWith(response ->
                response.status(200)
    );
@uglyog uglyog added the bug Indicates an unexpected problem or unintended behavior label Oct 23, 2024
@uglyog
Copy link
Member

uglyog commented Oct 23, 2024

WARNING: sendResponseHeaders: being invoked with a content length for a HEAD request

This is because HEAD requests can not have a body. If you don't set a body, you won't get that message. But it is a warning, it won't fail the test.

rholshausen added a commit that referenced this issue Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants