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

Projects
None yet
2 participants
@wilzbach
Contributor

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.

Show outdated Hide outdated http/vibe/http/server.d
*/
string path;
ref string path() @safe {

This comment has been minimized.

@wilzbach

wilzbach Jul 6, 2017

Contributor

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)
@wilzbach

wilzbach Jul 6, 2017

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Jul 6, 2017

Member

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).

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

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment