Add an API to expose the server's cookie domain.
Bug: http://b/3041920
Change-Id: I5c8cce92d68a74a18a8b2ea0f75f6b48ab3601d5
diff --git a/src/main/java/com/google/mockwebserver/MockWebServer.java b/src/main/java/com/google/mockwebserver/MockWebServer.java
index a938a27..ba92458 100644
--- a/src/main/java/com/google/mockwebserver/MockWebServer.java
+++ b/src/main/java/com/google/mockwebserver/MockWebServer.java
@@ -106,6 +106,16 @@
}
/**
+ * Returns a cookie domain for this server. This returns the server's
+ * non-loopback host name if it is known. Otherwise this returns ".local"
+ * for this server's loopback name.
+ */
+ public String getCookieDomain() {
+ String hostName = getHostName();
+ return hostName.contains(".") ? hostName : ".local";
+ }
+
+ /**
* Sets the number of bytes of the POST body to keep in memory to the given
* limit.
*/