本文整理了Java中retrofit2.Call.request()
方法的一些代码示例,展示了Call.request()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Call.request()
方法的具体详情如下:
包路径:retrofit2.Call
类名称:Call
方法名:request
[英]The original HTTP request.
[中]原始HTTP请求。
代码示例来源:origin: square/retrofit
@Override public Request request() {
return delegate.request();
}
}
代码示例来源:origin: square/retrofit
@Override public Request request() {
return delegate.request();
}
代码示例来源:origin: square/retrofit
@Override public void onFailure(Call<Page> call, Throwable t) {
System.out.println(call.request().url() + ": failed: " + t);
}
});
代码示例来源:origin: resilience4j/resilience4j
@Override
public Request request() {
return call.request();
}
}
代码示例来源:origin: com.squareup.retrofit2/retrofit
@Override public Request request() {
return delegate.request();
}
}
代码示例来源:origin: square/retrofit
@Override public Request request() {
return getDelegate().request();
}
}
代码示例来源:origin: square/retrofit
@Override public void onResponse(Call<Page> call, Response<Page> response) {
if (!response.isSuccessful()) {
System.out.println(call.request().url() + ": failed: " + response.code());
return;
}
// Print this page's URL and title.
Page page = response.body();
HttpUrl base = response.raw().request().url();
System.out.println(base + ": " + page.title);
// Enqueue its links for visiting.
for (String link : page.links) {
HttpUrl linkUrl = base.resolve(link);
if (linkUrl != null && fetchedUrls.add(linkUrl)) {
crawlPage(linkUrl);
}
}
}
代码示例来源:origin: Graylog2/graylog2-server
return Optional.of(transformer.apply(response.body()));
} else {
LOG.warn("Unable to call {} on node <{}>, result: {}", call.request().url(), node, response.message());
return Optional.<FinalResponseType>empty();
LOG.warn("Unable to call {} on node <{}>", call.request().url(), node, e);
return Optional.<FinalResponseType>empty();
代码示例来源:origin: resilience4j/resilience4j
@Test
public void passThroughCallsToDecoratedObject() throws IOException {
final Call<String> call = mock(StringCall.class);
final Call<String> decorated = new DecoratedCall<>(call);
decorated.cancel();
Mockito.verify(call).cancel();
decorated.enqueue(null);
Mockito.verify(call).enqueue(any());
decorated.isExecuted();
Mockito.verify(call).isExecuted();
decorated.isCanceled();
Mockito.verify(call).isCanceled();
decorated.clone();
Mockito.verify(call).clone();
decorated.request();
Mockito.verify(call).request();
decorated.execute();
Mockito.verify(call).execute();
}
代码示例来源:origin: rickfast/consul-client
private <T> Response<T> executeCall(Call<T> call) {
try {
return call.execute();
} catch (IOException e) {
eventHandler.httpRequestFailure(call.request(), e);
throw new ConsulException(e);
}
}
代码示例来源:origin: mapbox/mapbox-java
@Test
public void build_radiusGetsAddedToListCorrectly() throws Exception {
MapboxTilequery client = MapboxTilequery.builder()
.accessToken(ACCESS_TOKEN)
.query("-122.42901,37.80633")
.mapIds("mapbox.mapbox-streets-v7")
.baseUrl(mockUrl.toString())
.radius(200)
.build();
assertTrue(client.cloneCall().request().url().toString()
.contains("radius=200"));
}
代码示例来源:origin: mapbox/mapbox-java
@Test
public void build_dedupeGetsAddedToListCorrectly() throws Exception {
MapboxTilequery client = MapboxTilequery.builder()
.accessToken(ACCESS_TOKEN)
.query("-122.42901,37.80633")
.mapIds("mapbox.mapbox-streets-v7")
.baseUrl(mockUrl.toString())
.dedupe(true)
.build();
assertTrue(client.cloneCall().request().url().toString()
.contains("dedupe=true"));
}
代码示例来源:origin: mapbox/mapbox-java
@Test
public void baseUrl_doesChangeTheRequestUrl() throws Exception {
MapboxGeocoding mapboxGeocoding = MapboxGeocoding.builder()
.accessToken(ACCESS_TOKEN)
.baseUrl("https://foobar.com")
.query(Point.fromLngLat(-77.03655, 38.89770))
.build();
assertTrue(mapboxGeocoding.cloneCall().request().url().toString()
.startsWith("https://foobar.com"));
}
代码示例来源:origin: mapbox/mapbox-java
@Test
public void build_originDestinationGetAddedToListCorrectly() throws Exception {
MapboxDirections directions = MapboxDirections.builder()
.destination(Point.fromLngLat(13.4930, 9.958))
.origin(Point.fromLngLat(1.234, 2.345))
.accessToken(ACCESS_TOKEN)
.build();
assertTrue(directions.cloneCall().request().url().toString()
.contains("1.234,2.345;13.493,9.958"));
}
代码示例来源:origin: mapbox/mapbox-java
@Test
public void origin_doesGetFormattedInUrlCorrectly() throws Exception {
MapboxDirections directions = MapboxDirections.builder()
.destination(Point.fromLngLat(13.4930, 9.958))
.origin(Point.fromLngLat(1.234, 2.345))
.accessToken(ACCESS_TOKEN)
.build();
assertTrue(directions.cloneCall().request().url().toString().contains("1.234,2.345;"));
}
代码示例来源:origin: mapbox/mapbox-java
@Test
public void accessToken_doesGetFormattedInUrlCorrectly() throws Exception {
MapboxDirections directions = MapboxDirections.builder()
.destination(Point.fromLngLat(13.4930, 9.958))
.origin(Point.fromLngLat(1.234, 2.345))
.accessToken(ACCESS_TOKEN)
.build();
assertTrue(directions.cloneCall().request().url().toString().contains("access_token=pk.XXX"));
}
代码示例来源:origin: mapbox/mapbox-java
@Test
public void steps_doesGetFormattedInUrlCorrectly() throws Exception {
MapboxDirections directions = MapboxDirections.builder()
.destination(Point.fromLngLat(13.4930, 9.958))
.origin(Point.fromLngLat(1.234, 2.345))
.steps(true)
.accessToken(ACCESS_TOKEN)
.build();
assertTrue(directions.cloneCall().request().url().toString().contains("steps=true"));
}
代码示例来源:origin: mapbox/mapbox-java
@Test
public void continueStraight_doesGetFormattedInUrlCorrectly() throws Exception {
MapboxDirections directions = MapboxDirections.builder()
.destination(Point.fromLngLat(13.4930, 9.958))
.origin(Point.fromLngLat(1.234, 2.345))
.continueStraight(true)
.accessToken(ACCESS_TOKEN)
.build();
assertTrue(directions.cloneCall().request().url().toString()
.contains("continue_straight=true"));
}
代码示例来源:origin: mapbox/mapbox-java
@Test
public void user_doesGetFormattedInUrlCorrectly() throws Exception {
MapboxDirections directions = MapboxDirections.builder()
.destination(Point.fromLngLat(13.4930, 9.958))
.origin(Point.fromLngLat(1.234, 2.345))
.user("foobar")
.accessToken(ACCESS_TOKEN)
.build();
assertTrue(directions.cloneCall().request().url().toString().contains("/foobar/"));
}
代码示例来源:origin: mapbox/mapbox-java
@Test
public void voiceInstructions_doesGetFormattedInUrlCorrectly() throws Exception {
MapboxDirections directions = MapboxDirections.builder()
.destination(Point.fromLngLat(13.4930, 9.958))
.origin(Point.fromLngLat(1.234, 2.345))
.accessToken(ACCESS_TOKEN)
.baseUrl("https://foobar.com")
.voiceInstructions(true)
.build();
assertThat(directions.cloneCall().request().url().toString(),
containsString("voice_instructions=true"));
}
内容来源于网络,如有侵权,请联系作者删除!