2016-07-27 9 views
0

Gibt es eine Möglichkeit, das Protokoll (http oder https) in Vaadin zu bekommen? Ich kann den Host und den Port bekommen, aber ich brauche auch das Protokoll.getProtocol() in vaadin

import com.vaadin.ui.UI; 

[...] 

UI.getCurrent().getPage().getLocation().getHost(); 
UI.getCurrent().getPage().getLocation().getPort(); 

Also brauche ich so etwas wie:

UI.getCurrent().getPage().getLocation().getProtocol(); 

Antwort

1

Du bist ziemlich viel da :-)

System.out.println("Scheme=[" + Page.getCurrent().getLocation().getScheme() + "]");

Scheme = [http]


mehr Optionen gemäß dem discusstion mit Andre unter Hinzufügen:

public class MyVaadinUI extends UI { 

    protected void init(VaadinRequest request) { 
     System.out.println("Location scheme=[" + Page.getCurrent().getLocation().getScheme() + "]"); 
     System.out.println("Web browser isSecureConnection=[" + Page.getCurrent().getWebBrowser().isSecureConnection() + "]"); 
     System.out.println("Request isSecure=[" + request.isSecure()+"]"); 
    } 
} 

Location scheme = [http]
Webbrowser isSecureConnection = [false]
Anfrage isSecure = [false]

+1

In Bezug auf was Sie wissen müssen, gibt es auch eine isSecure() -Eigenschaft, die Sie über http/s –

+0

@ AndréSchild erzählt Kannst du ein Code-Beispiel teilen? Das 'URI'-Objekt, das von der' getLocation() '- Methode zurückgegeben wird, scheint eine solche Methode nicht verfügbar zu machen. – Morfic

+0

@ AndréSchild vielleicht 'Page.getCurrent(). GetWebBrowser(). IsSecureConnection()'? – Morfic