You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While trying out the rest example using the firefox RESTClient to send the request, I got a stack trace indicating the the content-type header was not set to "application/json" as it expected. The actual value sent down was "application/json; charset=UTF-8". The method jsonMethodHandler in http/rest.d expected the exact string "application/json". By importing std.algorithm and using the check:
enforce(!req.headers["Content-Type"].findSplit("application/json")[1].empty, "The Content-Type header needs to be set to application/json.");
I was able to get the response i expected. There needs to be some better handling when additional information is present in the header.
The text was updated successfully, but these errors were encountered:
One way to improve the handling in general would be to add a full header parser (e.g. issue #12) and not have standard headers in the req.headers map at all, which would also have the nice side effect to reduce the number of required memory allocations. I haven't decided yet which way has the better arguments for it.
For now, there are generally some special properties in HttpRequest/HttpResponse and I've also added contentType/contentTypeParameters, which is used everywhere now instead of manual str.split(';').
While trying out the rest example using the firefox RESTClient to send the request, I got a stack trace indicating the the content-type header was not set to "application/json" as it expected. The actual value sent down was "application/json; charset=UTF-8". The method jsonMethodHandler in http/rest.d expected the exact string "application/json". By importing std.algorithm and using the check:
enforce(!req.headers["Content-Type"].findSplit("application/json")[1].empty, "The Content-Type header needs to be set to application/json.");
I was able to get the response i expected. There needs to be some better handling when additional information is present in the header.
The text was updated successfully, but these errors were encountered: