本文整理了Java中com.squareup.okhttp.HttpUrl.url()
方法的一些代码示例,展示了HttpUrl.url()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpUrl.url()
方法的具体详情如下:
包路径:com.squareup.okhttp.HttpUrl
类名称:HttpUrl
方法名:url
暂无
代码示例来源:origin: com.squareup.okhttp/mockwebserver
/**
* Returns a URL for connecting to this server.
* @param path the request path, such as "/".
*/
@Deprecated
public URL getUrl(String path) {
return url(path).url();
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-batch
@VisibleForTesting
void logSuccess(@Nullable String taskId) {
if (taskId == null) {
LOG.info("ANALYSIS SUCCESSFUL");
} else {
Map<String, String> metadata = new LinkedHashMap<>();
String effectiveKey = projectReactor.getRoot().getKeyWithBranch();
metadata.put("projectKey", effectiveKey);
metadata.put("serverUrl", publicUrl());
URL dashboardUrl = HttpUrl.parse(publicUrl()).newBuilder()
.addPathSegment("dashboard").addPathSegment("index").addPathSegment(effectiveKey)
.build()
.url();
metadata.put("dashboardUrl", dashboardUrl.toExternalForm());
URL taskUrl = HttpUrl.parse(publicUrl()).newBuilder()
.addPathSegment("api").addPathSegment("ce").addPathSegment("task")
.addQueryParameter("id", taskId)
.build()
.url();
metadata.put("ceTaskId", taskId);
metadata.put("ceTaskUrl", taskUrl.toExternalForm());
LOG.info("ANALYSIS SUCCESSFUL, you can browse {}", dashboardUrl);
LOG.info("Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report");
LOG.info("More about the report processing at {}", taskUrl);
dumpMetadata(metadata);
}
}
代码示例来源:origin: JmStefanAndroid/PVCloudGroupn
Log.e(TAG, "URL:"+response.request().httpUrl().url().toString()+" result=" + resultStr);
if (response.request().httpUrl().url().toString().contains(Contants.API.BASE_URL)) {
try {//尝试解析为基础数据
BaseRespMsg respMsg = mGson.fromJson(resultStr, BaseRespMsg.class);
代码示例来源:origin: org.hobsoft.microbrowser/microbrowser-tck
@Test
public void getHrefWhenLinkAndRelativeHrefReturnsAbsoluteUrl()
{
server().enqueue(new MockResponse().setBody("<html><head>"
+ "<link rel='x' href='x'/>"
+ "</head></html>"));
URL actual = newBrowser().get(url(server()))
.getLink("x")
.getHref();
assertThat("link href", actual, is(server().url("/x").url()));
}
代码示例来源:origin: org.hobsoft.microbrowser/microbrowser-tck
@Test
public void getHrefWhenAnchorAndRelativeHrefReturnsAbsoluteUrl()
{
server().enqueue(new MockResponse().setBody("<html><body>"
+ "<a rel='r' href='x'/>"
+ "</body></html>"));
URL actual = newBrowser().get(url(server()))
.getLink("r")
.getHref();
assertThat("link href", actual, is(server().url("/x").url()));
}
代码示例来源:origin: mike-neck/javajo-gradle
public List<Translation> translate(String text) {
URL url = new HttpUrl.Builder()
.scheme("https")
.host("api.codic.jp")
.addPathSegment("v1")
.addPathSegment("engine")
.addPathSegment("translate.json")
.addQueryParameter("text", text)
.build()
.url();
Request request = new Builder()
.url(url)
.addHeader(CODIC_HTTP_AUTH_HEADER, "Bearer " + accessToken)
.get()
.build();
try {
Response response = new OkHttpClient().newCall(request).execute();
int code = response.code();
if (code != 200) {
throw new CodicException("Exception in calling API[" + API_ENTRY_URL + "] with status " + code + ".");
}
Genson genson = new GensonBuilder().useMethods(true).create();
String string = response.body().string();
return genson.deserialize(string, new GenericType<List<Translation>>() {});
} catch (IOException e) {
throw new CodicException("Exception in calling API[" + API_ENTRY_URL + "].", e);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!