mirror of
https://github.com/square/okhttp.git
synced 2026-01-17 08:42:25 +03:00
Merge pull request #1469 from nashira/master
null out Request.Builder.url when setting urlString
This commit is contained in:
@@ -114,6 +114,18 @@ public final class RequestTest {
|
||||
assertEquals(new URL("http://localhost/api"), request.url());
|
||||
}
|
||||
|
||||
@Test public void newBuilderUrlResetsUrl() throws Exception {
|
||||
Request requestWithoutCache = new Request.Builder().url("http://localhost/api").build();
|
||||
Request builtRequestWithoutCache = requestWithoutCache.newBuilder().url("http://localhost/api/foo").build();
|
||||
assertEquals(new URL("http://localhost/api/foo"), builtRequestWithoutCache.url());
|
||||
|
||||
Request requestWithCache = new Request.Builder().url("http://localhost/api").build();
|
||||
// cache url object
|
||||
requestWithCache.url();
|
||||
Request builtRequestWithCache = requestWithCache.newBuilder().url("http://localhost/api/foo").build();
|
||||
assertEquals(new URL("http://localhost/api/foo"), builtRequestWithCache.url());
|
||||
}
|
||||
|
||||
@Test public void cacheControl() throws Exception {
|
||||
Request request = new Request.Builder()
|
||||
.cacheControl(new CacheControl.Builder().noCache().build())
|
||||
|
||||
@@ -146,7 +146,8 @@ public final class Request {
|
||||
|
||||
public Builder url(String url) {
|
||||
if (url == null) throw new IllegalArgumentException("url == null");
|
||||
urlString = url;
|
||||
this.urlString = url;
|
||||
this.url = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user