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

More lazy loading in HTTPServerRequest #1801

Merged
merged 1 commit into from Jul 5, 2017

Conversation

Projects
None yet
2 participants
@wilzbach
Contributor

wilzbach commented Jun 29, 2017

Similarly to #1677

Some values are actually a bit problematic thanks to D's type concept (mutable methods!), for example consider the method fullURL method:

@property URL fullURL()
const @safe {
     URL url;
...
	url.username = this.username; //  Error: mutable method vibe.http.server.HTTPServerRequest.username is not callable using a const object
	url.password = this.password; //  Error: mutable method vibe.http.server.HTTPServerRequest.password is not callable using a const object
        return url;
}

I initially had the idea to hack the type system with something like assumeConst:

import std.traits;
private auto assumeConst(T)(T t) @trusted
    if (isFunctionPointer!T || isDelegate!T)
{
    enum attrs = functionAttributes!T | FunctionAttribute.const_;
    return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) t;
}

But. of course, without success

@wilzbach

This comment has been minimized.

Show comment
Hide comment
@wilzbach

wilzbach Jul 4, 2017

Contributor

If I'm not overlooking something, I think this needs to set _form to .init first, or it would try to access the null field.

Excellent catch! Fixed.

Contributor

wilzbach commented Jul 4, 2017

If I'm not overlooking something, I think this needs to set _form to .init first, or it would try to access the null field.

Excellent catch! Fixed.

@s-ludwig s-ludwig merged commit f40cf2e into vibe-d:master Jul 5, 2017

2 of 4 checks passed

codecov/patch 35.714% of diff hit (target 37.016%)
Details
codecov/project 36.98% (-0.037%) compared to 64a63e2
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@wilzbach wilzbach deleted the wilzbach:more-lazy-loading branch Jul 6, 2017

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