Skip to content
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

Initialize parseURL and parseQueryString lazily #1821

Merged
merged 2 commits into from
Jul 7, 2017

Conversation

wilzbach
Copy link
Member

@wilzbach wilzbach commented Jul 6, 2017

This makes the last two options of HTTPServerSettings lazy. As mentioned before, lazy intitialization costs us constness of the methods.

*/
string path;
ref string path() @safe {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bit of code that expects these variables to be mutable (hence ref), e.g.

http/vibe/http/auth/basic_auth.d(100,4): Error: function vibe.http.server.HTTPServerRequest.username () is not callable using argument types (string)
http/vibe/http/auth/digest_auth.d(119,4): Error: function vibe.http.server.HTTPServerRequest.username () is not callable using argument types (string)
http/vibe/http/server.d(391,2): Error: function vibe.http.server.HTTPServerRequest.path () is not callable using argument types (string)
http/vibe/http/server.d(392,2): Error: function vibe.http.server.HTTPServerRequest.queryString () is not callable using argument types (string)
http/vibe/http/server.d(393,2): Error: function vibe.http.server.HTTPServerRequest.username () is not callable using argument types (string)
http/vibe/http/server.d(394,2): Error: function vibe.http.server.HTTPServerRequest.password () is not callable using argument types (string)

@s-ludwig
Copy link
Member

s-ludwig commented Jul 6, 2017

I'd say lets postpone the URL/path part for now, as the best solution may still shift w.r.t. the path/URL implementation. The query string makes sense in any case, though.

What I think makes sense for parseURL even now, is to always parse the URL, eagerly (it's de-facto @nogc and very lightweight), but to keep req.path tied to parseURL for now, because that actually may allocate memory.

But .path is ugly anyway. With vibe-core, this could be an InetPath, which doesn't allocate upon construction, and would also behave correctly w.r.t. URL encoding. Currently there are issues with encoded slashes within path segments (in the router and arguably also in the file server). So a transition path to InetPath should be the goal (not sure if alias toString this; in InetPath is a good idea).

@s-ludwig s-ludwig merged commit fbc6876 into vibe-d:master Jul 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants