本文整理了Java中com.google.appengine.api.urlfetch.HTTPResponse.getFinalUrl()
方法的一些代码示例,展示了HTTPResponse.getFinalUrl()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HTTPResponse.getFinalUrl()
方法的具体详情如下:
包路径:com.google.appengine.api.urlfetch.HTTPResponse
类名称:HTTPResponse
方法名:getFinalUrl
暂无
代码示例来源:origin: com.threewks.thundr/thundr-gae
@Override
public URI getUri() {
try {
// final url is only non-null when we follow redirects
URL finalUrl = response().getFinalUrl();
return finalUrl == null ? url.toURI() : finalUrl.toURI();
} catch (URISyntaxException e) {
throw new HttpResponseException(e, "Uri cannot be parsed: %s", e.getMessage());
}
}
代码示例来源:origin: com.squareup.retrofit/retrofit
static Response parseResponse(HTTPResponse response, HTTPRequest creatingRequest) {
// Response URL will be null if it is the same as the request URL.
URL responseUrl = response.getFinalUrl();
String urlString = (responseUrl != null ? responseUrl : creatingRequest.getURL()).toString();
int status = response.getResponseCode();
List<HTTPHeader> fetchHeaders = response.getHeaders();
List<Header> headers = new ArrayList<Header>(fetchHeaders.size());
String contentType = "application/octet-stream";
for (HTTPHeader fetchHeader : fetchHeaders) {
String name = fetchHeader.getName();
String value = fetchHeader.getValue();
if ("Content-Type".equalsIgnoreCase(name)) {
contentType = value;
}
headers.add(new Header(name, value));
}
TypedByteArray body = null;
byte[] fetchBody = response.getContent();
if (fetchBody != null) {
body = new TypedByteArray(contentType, fetchBody);
}
return new Response(urlString, status, "", headers, body);
}
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
public void handle(HTTPResponse response) throws Exception {
URL finalURL = response.getFinalUrl();
Assert.assertEquals(getUrl(""), finalURL);
}
});
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
public void handle(HTTPResponse response) throws Exception {
URL finalURL = response.getFinalUrl();
Assert.assertEquals(getUrl(""), finalURL);
}
});
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
@Test
public void testFollowRedirectsExternal() throws Exception {
final URL redirectUrl = new URL("http://google.com/");
final String expectedDestinationURLPrefix = "http://www.google.";
FetchOptions options = FetchOptions.Builder.followRedirects();
HTTPRequest request = new HTTPRequest(redirectUrl, HTTPMethod.GET, options);
URLFetchService service = URLFetchServiceFactory.getURLFetchService();
HTTPResponse response = service.fetch(request);
String destinationUrl = response.getFinalUrl().toString();
assertTrue("Did not get redirected.", destinationUrl.startsWith(expectedDestinationURLPrefix));
}
内容来源于网络,如有侵权,请联系作者删除!