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

Unable to process REST call correctly #154

Closed
ncoe opened this Issue Jan 9, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@ncoe
Contributor

ncoe commented Jan 9, 2013

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.

s-ludwig added a commit that referenced this issue Jan 9, 2013

@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Jan 9, 2013

Member

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(';').

Member

s-ludwig commented Jan 9, 2013

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(';').

@ncoe

This comment has been minimized.

Show comment
Hide comment
@ncoe

ncoe Jan 10, 2013

Contributor

Thanks for the quick response. That commit works great.

Contributor

ncoe commented Jan 10, 2013

Thanks for the quick response. That commit works great.

@ncoe ncoe closed this Jan 10, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment