use of retrofit2.http.Path in project retrofit by square.
the class RequestBuilderTest method getWithEncodedPathStillPreventsRequestSplitting.
@Test
public void getWithEncodedPathStillPreventsRequestSplitting() {
class Example {
//
@GET("/foo/bar/{ping}/")
Call<ResponseBody> method(@Path(value = "ping", encoded = true) String ping) {
return null;
}
}
Request request = buildRequest(Example.class, "baz/\r\npong");
assertThat(request.method()).isEqualTo("GET");
assertThat(request.headers().size()).isZero();
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/baz/pong/");
assertThat(request.body()).isNull();
}
use of retrofit2.http.Path in project retrofit by square.
the class RequestBuilderTest method normalPostWithPathParam.
@Test
public void normalPostWithPathParam() {
class Example {
//
@POST("/foo/bar/{ping}/")
Call<ResponseBody> method(@Path("ping") String ping, @Body RequestBody body) {
return null;
}
}
RequestBody body = RequestBody.create(TEXT_PLAIN, "Hi!");
Request request = buildRequest(Example.class, "pong", body);
assertThat(request.method()).isEqualTo("POST");
assertThat(request.headers().size()).isZero();
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/pong/");
assertBody(request.body(), "Hi!");
}
use of retrofit2.http.Path in project retrofit by square.
the class RequestBuilderTest method getWithEncodedPathSegments.
@Test
public void getWithEncodedPathSegments() {
class Example {
//
@GET("/foo/bar/{ping}/")
Call<ResponseBody> method(@Path(value = "ping", encoded = true) String ping) {
return null;
}
}
Request request = buildRequest(Example.class, "baz/pong/more");
assertThat(request.method()).isEqualTo("GET");
assertThat(request.headers().size()).isZero();
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/baz/pong/more/");
assertThat(request.body()).isNull();
}
use of retrofit2.http.Path in project retrofit by square.
the class RequestBuilderTest method getWithUnencodedPathSegmentsPreventsRequestSplitting.
@Test
public void getWithUnencodedPathSegmentsPreventsRequestSplitting() {
class Example {
//
@GET("/foo/bar/{ping}/")
Call<ResponseBody> method(@Path(value = "ping", encoded = false) String ping) {
return null;
}
}
Request request = buildRequest(Example.class, "baz/\r\nheader: blue");
assertThat(request.method()).isEqualTo("GET");
assertThat(request.headers().size()).isZero();
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/baz%2F%0D%0Aheader:%20blue/");
assertThat(request.body()).isNull();
}
use of retrofit2.http.Path in project retrofit by square.
the class RequestBuilderTest method getWithEncodedPathParam.
@Test
public void getWithEncodedPathParam() {
class Example {
//
@GET("/foo/bar/{ping}/")
Call<ResponseBody> method(@Path(value = "ping", encoded = true) String ping) {
return null;
}
}
Request request = buildRequest(Example.class, "po%20ng");
assertThat(request.method()).isEqualTo("GET");
assertThat(request.headers().size()).isZero();
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/po%20ng/");
assertThat(request.body()).isNull();
}
Aggregations