On Sat, 12 Nov 2016 10:47:04 GMT, Kingsleyh wrote:
Hi
I am able to send headers with a GET request but they don't seem to be getting received by the Vibe Server when using a POST or PUT request.
e.g:
requestHTTP(route, (scope req) { req.method = HTTPMethod.POST; req.writeJsonBody(json); req.headers["Cookie"] = cookie; req.headers["Example"] = "Hello Example"; }, (scope res) { auto r = res.bodyReader.readAllUTF8(); writeln(r); });
I'm basically doing a post back to a Vibe.d server and on the server I don't see the headers;
void example(HTTPServerRequest req, HTTPServerResponse res) { writeln(req.headers); // headers don't include the ones I set on the request }
Is this a bug? Or am I doing something wrong?
Thanks for the help :)
The headers just need to be set before the call to writeJsonBody
. See also this recent ticket: #1614