@Test public void exposesDecodedPath() throws Exception { Url url = Url.Builder.url("http://localhost/foo%20bar").build(); assertThat(url.toURI().getPath(), is("/foo bar")); }
@Test public void identifiesCorrectlyIfUrlIsFullyQualified() throws Exception { Url fqUrl = url("http://example.com").build(); assertThat(fqUrl.isFullyQualified(), is(true)); assertThat(fqUrl.isAbsolute(), is(false)); assertThat(fqUrl.isRelative(), is(true)); Url nonFqUrl = url("/somepath").build(); assertThat(nonFqUrl.isFullyQualified(), is(false)); assertThat(nonFqUrl.isAbsolute(), is(true)); assertThat(nonFqUrl.isRelative(), is(false)); }
public Builder(HttpMethod method, String uri) { this(); this.method = requireNonNull(method); this.url = Url.Builder.url(uri).build(); this.secure = url.isSecure(); }
@Test public void spaceIsAlsoPlusIsAlsoHex20() { String ENCODED_SPACE = "/customercare/subscribe.html%20sessid=nXF5jQ8rTW3bAbh6djb2hYJE3D.web-app-02"; String path = "/customercare/subscribe.html+sessid=nXF5jQ8rTW3bAbh6djb2hYJE3D.web-app-02"; assertThat(url(path).build().encodedUri(), is(path)); assertThat(url(ENCODED_SPACE).build().encodedUri(), is(ENCODED_SPACE)); }
/** * Sets the request URI. * * @param uri URI * @return {@code this} */ @Override public Builder uri(String uri) { return this.url(Url.Builder.url(uri).build()); }
/** * Sets the request URI. * * @param uri URI * @return {@code this} */ public Builder uri(String uri) { return this.url(Url.Builder.url(uri).build()); }
/** * Creates a builder with an HTTP method and URI. * * @param method HTTP method * @param uri URI */ public Builder(HttpMethod method, String uri) { this.method = method; this.url = Url.Builder.url(uri).build(); this.secure = url.isSecure(); headers(new HttpHeaders.Builder()); }
/** * Sets the request URI. * * @param uri URI * @return {@code this} */ public Builder uri(String uri) { return this.url(Url.Builder.url(uri).build()); }
public Builder() { this.url = Url.Builder.url("/").build(); this.headers = new HttpHeaders.Builder(); this.body = new byte[0]; this.cookies = new ArrayList<>(); }
@Test public void absentPortIsStoredInAuthorityAsMinusOne() throws Exception { int port = url("http://example.com") .build().authority().get().port(); assertThat(port, is(-1)); }
@Test public void portNumberIsStoredInAuthority() throws Exception { int port = url("http://ecom.com:8080") .build().authority().get().port(); assertThat(port, is(8080)); }
@Test public void extractsTheHostUrl() throws Exception { Optional<String> host = url("http://ecom.com").build().host(); assertThat(host, isValue("ecom.com")); }
/** * Sets the request URI. * * @param uri URI * @return {@code this} */ public Builder uri(String uri) { return this.url(Url.Builder.url(uri).build()); }
public Builder(HttpMethod method, String uri) { this(); this.method = requireNonNull(method); this.url = Url.Builder.url(uri).build(); this.secure = url.isSecure(); }
@Test public void createARequestWithStreamingUrl() { LiveHttpRequest request = get("http://www.hotels.com").build(); assertThat(request.url(), is(url("http://www.hotels.com").build())); }
@Test(dataProvider = "pathSegmentAllowedChars") public void shouldNotEncodeAllowedCharactersInPath(String character) { String path = "/customercare/subscribe.html" + character + "sessid=nXF5jQ8rTW3bAbh6djb2hYJE3D.web-app-02"; assertThat(url(path).build().encodedUri(), is(path)); } @Test
@Test public void shouldCreateWithSchemeAndHost() throws CharacterCodingException { assertThat("http://example.com", is(new Url.Builder() .scheme("http") .authority("example.com") .path("") .build() .toString())); }
/** * Creates a new {@link Builder} object with default attributes. */ public Builder() { this.url = Url.Builder.url("/").build(); this.headers = new HttpHeaders.Builder(); this.body = new ByteStream(Flux.empty()); }
/** * Sets the request URI. * * @param uri URI * @return {@code this} */ public Builder uri(String uri) { return this.url(Url.Builder.url(uri).build()); }