@Override
public Sequence eval(final Sequence[] args, final HttpRequest request) throws XPathException {
final Sequence result;
if(isCalledAs(qnScheme.getLocalName())) {
result = new StringValue(request.getScheme());
} else if(isCalledAs(qnHostname.getLocalName())) {
result = new StringValue(request.getHostname());
} else if(isCalledAs(qnPort.getLocalName())) {
result = new IntegerValue(request.getPort());
} else if(isCalledAs(qnPath.getLocalName())) {
result = new StringValue(request.getPath());
} else if(isCalledAs(qnQuery.getLocalName())) {
final String query = request.getQuery();
if(query == null) {
result = Sequence.EMPTY_SEQUENCE;
} else {
result = new StringValue(query);
}
} else if(isCalledAs(qnUri.getLocalName())) {
result = new StringValue(request.getURI());
} else {
throw new XPathException(this, "Unknown function call: " + getSignature());
}