From 2ca264f51e00c45c656270b27feb08ae041bbd88 Mon Sep 17 00:00:00 2001 From: Philip Youssef Date: Thu, 7 Apr 2016 14:04:58 -0700 Subject: [PATCH] Make WS properly set virtualHost --- framework/src/play/libs/WS.java | 6 ++++++ framework/src/play/libs/ws/WSAsync.java | 3 +++ 2 files changed, 9 insertions(+) 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);