diff --git a/framework/src/play/libs/WS.java b/framework/src/play/libs/WS.java index 5bb54d0aa2..b1047f0a40 100644 --- a/framework/src/play/libs/WS.java +++ b/framework/src/play/libs/WS.java @@ -230,6 +230,7 @@ public static abstract class WSRequest { public FileParam[] fileParams; public Map headers = new HashMap(); public Map parameters = new LinkedHashMap(); + public String virtualHost; public String mimeType; public boolean followRedirects = true; /** @@ -263,6 +264,11 @@ public WSRequest mimeType(String mimeType) { this.mimeType = mimeType; return this; } + + public WSRequest virtualHost(String virtualHost) { + this.virtualHost = virtualHost; + return this; + } /** * define client authentication for a server host diff --git a/framework/src/play/libs/ws/WSAsync.java b/framework/src/play/libs/ws/WSAsync.java index 939c78306a..4366539861 100644 --- a/framework/src/play/libs/ws/WSAsync.java +++ b/framework/src/play/libs/ws/WSAsync.java @@ -374,6 +374,9 @@ private BoundRequestBuilder prepare(BoundRequestBuilder builder) { for (String key: this.headers.keySet()) { builder.addHeader(key, headers.get(key)); } + if (this.virtualHost != null) { + builder.setVirtualHost(this.virtualHost); + } builder.setFollowRedirects(this.followRedirects); PerRequestConfig perRequestConfig = new PerRequestConfig(); perRequestConfig.setRequestTimeoutInMs(this.timeout * 1000);