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

REST out header param is expected from the server #1933

WebFreak001 opened this Issue Sep 18, 2017 · 0 comments


None yet
1 participant

WebFreak001 commented Sep 18, 2017

The documentation says that out REST headerParams are response headers that you don't send to the server, but if you don't send the header to the server it complains about a missing non-optional header parameter:

import vibe.d;

shared static this()
	auto settings = new HTTPServerSettings;
	settings.port = 3000;
	settings.bindAddresses = ["::1", ""];
	auto router = new URLRouter;
	router.registerRestInterface(new Rest);
	listenHTTP(settings, router);

interface IRest
	@headerParam("a", "X-A-Header")
	int getFoo(out string a);

class Rest : IRest
	int getFoo(out string a)
		a = "hi";
		return 0;

Now open http://localhost:3000/foo and you would expect it to return 0 and send back the X-A-Header with hi as value, however it returns this:

400 - Bad Request

Missing non-optional header parameter 'X-A-Header'.

Internal error information:
vibe.http.common.HTTPStatusException@../../home/webfreak/.dub/packages/vibe-d-0.7.32/vibe-d/source/vibe/web/rest.d(1072): Missing non-optional header parameter 'X-A-Header'.
??:? pure @safe bool std.exception.enforce!(bool).enforce(bool, lazy object.Throwable) [0x217bfd4]
??:? bool vibe.http.common.enforceHTTP!(bool).enforceHTTP(bool, vibe.http.status.HTTPStatus, lazy immutable(char)[], immutable(char)[], int) [0x2188383]
??:? bool vibe.http.common.enforceBadRequest!(bool).enforceBadRequest(bool, lazy immutable(char)[], immutable(char)[], int) [0x218831c]
??:? void!(int app.IRest.getFoo(out immutable(char)[]), 0uL, app.Rest).jsonMethodHandler(app.Rest, ref!(app.Rest).RestInterface).handler(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) [0x218569a]
??:? _D4vibe4http6router9URLRouter13handleRequestMFC4vibe4http6server17HTTPServerRequestC4vibe4http6server18HTTPServerResponseZ21__T9__lambda4TmTAAyaZ9__lambda4MFmMAAyaZb [0x222c8ce]
??:? const(bool function(immutable(char)[], scope bool delegate(ulong, scope immutable(char)[][]))) vibe.http.router.MatchTree!(vibe.http.router.Route).MatchTree.doMatch [0x222d6b5]
??:? bool vibe.http.router.MatchTree!(vibe.http.router.Route).MatchTree.match(immutable(char)[], scope bool delegate(ulong, scope immutable(char)[][])) [0x222cf07]
??:? void vibe.http.router.URLRouter.handleRequest(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse) [0x222c56d]
??:? bool vibe.http.server.handleRequest(,, vibe.http.server.HTTPListenInfo, ref vibe.http.server.HTTPServerSettings, ref bool) [0x2269a60]
??:? void vibe.http.server.handleHTTPConnection(, vibe.http.server.HTTPListenInfo) [0x2267ffc]
??:? void vibe.http.server.listenHTTPPlain(vibe.http.server.HTTPServerSettings).doListen(vibe.http.server.HTTPListenInfo, bool, bool).__lambda4( [0x226799c]
??:? void vibe.core.drivers.libevent2_tcp.ClientTask.execute() [0x231aa24]
??:? void vibe.core.core.makeTaskFuncInfo!(void delegate()).makeTaskFuncInfo(ref void delegate()).callDelegate(vibe.core.core.TaskFuncInfo*) [0x21d8a3f]
??:? void [0x22a5c76]
??:? void [0x23bbc9b]
??:? fiber_entryPoint [0x23bb9fe]
??:? [0xffffffff]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment