Empty header value not allowed

177 views
Skip to first unread message

Alin Ghitulan

unread,
Jul 25, 2016, 10:38:35 AM7/25/16
to wiremock-user
Hi,

I've recently started using WireMock and it seems I get a strange behavior when trying something like:

wireMockServer.addStubMapping(get(urlEqualTo("/admin/agent/registered"))
        .withHeader("apikey", equalTo(""))
        .willReturn(aResponse()
        .withStatus(200)
        .withBody("[\n" +
        "  {\n" +
       
...
       
"  }\n" +
       
"]")).build());

I am using WebClient (C#) to make the actual HTTP request which allows me to do the following:

webClient.Headers.Add("apikey", "");

This means that sometimes my value is an empty string. 

I can observe the following behavior:
  • If I don't specify "withHeader" I will get a 404 from Jetty when value is empty string
  • If I specify it I will get a 500 from Jetty (using Postman I can see some more details:
<body>
        <h2>HTTP ERROR: 500</h2>
        <p>Problem accessing /admin/agent/registered. Reason:

            <pre>    java.lang.IllegalStateException: No value for apikey</pre>
        </p>
        <hr />
        <i>
            <small>Powered by Jetty://</small>
        </i>
</body>


 Please let me know if I'm missing something. Or if I can provide more info.

Alin

Tom Akehurst

unread,
Jul 25, 2016, 10:39:29 AM7/25/16
to wiremock-user
This is a known bug, and is next on my list to fix.

Alin Ghitulan

unread,
Jul 25, 2016, 10:49:10 AM7/25/16
to wiremock-user
Thank you. I suppose there is no quick workaround available?
How could I be able to track when the changes are on maven?

Alin

Tom Akehurst

unread,
Jul 25, 2016, 10:53:58 AM7/25/16
to wiremock-user
Unfortunately no workarounds presently.

I announce releases here (on the mailing list) so provided you've got email notifications turned on you'll see it.
Reply all
Reply to author
Forward
0 new messages