Can't really add a constructive comment on that. This line was written by Marc.
Variable "protocol" is at the moment not used exactly because it's always http when coming from geoadmin. Marc should looking at the issue