本文整理了Java中okhttp3.internal.Version.userAgent()
方法的一些代码示例,展示了Version.userAgent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.userAgent()
方法的具体详情如下:
包路径:okhttp3.internal.Version
类名称:Version
方法名:userAgent
暂无
代码示例来源:origin: square/okhttp
private void updateReports() {
final CountDownLatch latch = new CountDownLatch(1);
newWebSocket("/updateReports?agent=" + Version.userAgent(), new WebSocketListener() {
@Override public void onClosing(WebSocket webSocket, int code, String reason) {
webSocket.close(1000, null);
latch.countDown();
}
@Override public void onFailure(WebSocket webSocket, Throwable t, Response response) {
latch.countDown();
}
});
try {
if (!latch.await(10, TimeUnit.SECONDS)) {
throw new IllegalStateException("Timed out waiting for count.");
}
} catch (InterruptedException e) {
throw new AssertionError();
}
}
}
代码示例来源:origin: square/okhttp
private String defaultUserAgent() {
String agent = Util.getSystemProperty("http.agent", null);
return agent != null ? toHumanReadableAscii(agent) : Version.userAgent();
}
代码示例来源:origin: square/okhttp
requestBuilder.header("User-Agent", Version.userAgent());
代码示例来源:origin: square/okhttp
.header("Host", Util.hostHeader(route.address().url(), true))
.header("Proxy-Connection", "Keep-Alive") // For HTTP/1.0 proxies like Squid.
.header("User-Agent", Version.userAgent())
.build();
代码示例来源:origin: com.squareup.okhttp3/okhttp
requestBuilder.header("User-Agent", Version.userAgent());
代码示例来源:origin: com.squareup.okhttp3/okhttp
.header("Host", Util.hostHeader(route.address().url(), true))
.header("Proxy-Connection", "Keep-Alive") // For HTTP/1.0 proxies like Squid.
.header("User-Agent", Version.userAgent())
.build();
代码示例来源:origin: jamesagnew/hapi-fhir
private void addUserAgentHeader(OkHttpRestfulRequest theHttpRequest, FhirContext theContext) {
theHttpRequest.addHeader("User-Agent", HttpClientUtil.createUserAgentString(theContext, Version.userAgent()));
}
代码示例来源:origin: westnordost/StreetComplete
@Override public void onRequest(@NonNull String url, @NonNull Callback cb, long requestHandle)
{
HttpUrl httpUrl = HttpUrl.parse(url + "?api_key=" + apiKey);
if (httpUrl == null) {
cb.onFailure(null, new IOException("HttpUrl failed to parse url=" + url));
}
else {
Request.Builder builder = new Request.Builder()
.url(httpUrl)
.tag(requestHandle)
.header("User-Agent", ApplicationConstants.USER_AGENT + " / " + Version.userAgent());
CacheControl cacheControl = cachePolicy.apply(httpUrl);
if (cacheControl != null) {
builder.cacheControl(cacheControl);
}
Request request = builder.build();
okClient.newCall(request).enqueue(cb);
}
}
}
代码示例来源:origin: org.nuxeo.client/nuxeo-java-client
protected String computeUserAgent() {
String nuxeoPart = " NuxeoJavaClient/";
try (InputStream inputStream = getClass().getResourceAsStream("/META-INF/nuxeo-java-client.properties")) {
Properties properties = new Properties();
properties.load(inputStream);
String nuxeoVersion = properties.getProperty("nuxeo.java.client.version");
nuxeoPart += nuxeoVersion;
} catch (IOException e) {
nuxeoPart += "Unknown";
}
return Version.userAgent() + nuxeoPart;
}
代码示例来源:origin: com.github.ljun20160606/okhttp-urlconnection
private String defaultUserAgent() {
String agent = System.getProperty("http.agent");
return agent != null ? Util.toHumanReadableAscii(agent) : Version.userAgent();
}
代码示例来源:origin: apache/servicemix-bundles
private String defaultUserAgent() {
String agent = System.getProperty("http.agent");
return agent != null ? toHumanReadableAscii(agent) : Version.userAgent();
}
代码示例来源:origin: com.squareup.okhttp3/okhttp-urlconnection
private String defaultUserAgent() {
String agent = Util.getSystemProperty("http.agent", null);
return agent != null ? toHumanReadableAscii(agent) : Version.userAgent();
}
代码示例来源:origin: huxq17/SwipeCardsView
/**
* Returns a request that creates a TLS tunnel via an HTTP proxy, or null if
* no tunnel is necessary. Everything in the tunnel request is sent
* unencrypted to the proxy server, so tunnels include only the minimum set of
* headers. This avoids sending potentially sensitive data like HTTP cookies
* to the proxy unencrypted.
*/
private Request createTunnelRequest() throws IOException {
return new Request.Builder()
.url(route.address().url())
.header("Host", Util.hostHeader(route.address().url()))
.header("Proxy-Connection", "Keep-Alive")
.header("User-Agent", Version.userAgent()) // For HTTP/1.0 proxies like Squid.
.build();
}
代码示例来源:origin: huxq17/tractor
/**
* Returns a request that creates a TLS tunnel via an HTTP proxy, or null if
* no tunnel is necessary. Everything in the tunnel request is sent
* unencrypted to the proxy server, so tunnels include only the minimum set of
* headers. This avoids sending potentially sensitive data like HTTP cookies
* to the proxy unencrypted.
*/
private Request createTunnelRequest() throws IOException {
return new Request.Builder()
.url(route.address().url())
.header("Host", Util.hostHeader(route.address().url()))
.header("Proxy-Connection", "Keep-Alive")
.header("User-Agent", Version.userAgent()) // For HTTP/1.0 proxies like Squid.
.build();
}
代码示例来源:origin: duzechao/OKHttpUtils
/**
* Returns a request that creates a TLS tunnel via an HTTP proxy, or null if no tunnel is
* necessary. Everything in the tunnel request is sent unencrypted to the proxy server, so tunnels
* include only the minimum set of headers. This avoids sending potentially sensitive data like
* HTTP cookies to the proxy unencrypted.
*/
private Request createTunnelRequest() throws IOException {
return new Request.Builder()
.url(route.address().url())
.header("Host", Util.hostHeader(route.address().url()))
.header("Proxy-Connection", "Keep-Alive")
.header("User-Agent", Version.userAgent()) // For HTTP/1.0 proxies like Squid.
.build();
}
代码示例来源:origin: duzechao/OKHttpUtils
/**
* Populates request with defaults and cookies.
*
* <p>This client doesn't specify a default {@code Accept} header because it doesn't know what
* content types the application is interested in.
*/
private Request networkRequest(Request request) throws IOException {
Request.Builder result = request.newBuilder();
if (request.header("Host") == null) {
result.header("Host", hostHeader(request.url()));
}
if (request.header("Connection") == null) {
result.header("Connection", "Keep-Alive");
}
if (request.header("Accept-Encoding") == null) {
transparentGzip = true;
result.header("Accept-Encoding", "gzip");
}
List<Cookie> cookies = client.cookieJar().loadForRequest(request.url());
if (!cookies.isEmpty()) {
result.header("Cookie", cookieHeader(cookies));
}
if (request.header("User-Agent") == null) {
result.header("User-Agent", Version.userAgent());
}
return result.build();
}
代码示例来源:origin: com.github.ljun20160606/okhttp
/**
* Returns a request that creates a TLS tunnel via an HTTP proxy. Everything in the tunnel request
* is sent unencrypted to the proxy server, so tunnels include only the minimum set of headers.
* This avoids sending potentially sensitive data like HTTP cookies to the proxy unencrypted.
*/
private Request createTunnelRequest() throws IOException {
Request request = new Request.Builder()
.url(route.address().url())
.header("Host", Util.hostHeader(route.address().url(), true))
.header("Proxy-Connection", "Keep-Alive") // For HTTP/1.0 proxies like Squid.
.header("User-Agent", Version.userAgent())
.build();
Request authenticateRequest = route.address().proxyAuthenticator().authenticate(request);
if (authenticateRequest == null) {
return request;
}
return authenticateRequest;
}
代码示例来源:origin: huxq17/SwipeCardsView
result.header("User-Agent", Version.userAgent());
代码示例来源:origin: huxq17/tractor
result.header("User-Agent", Version.userAgent());
代码示例来源:origin: apache/servicemix-bundles
.header("Host", Util.hostHeader(route.address().url(), true))
.header("Proxy-Connection", "Keep-Alive") // For HTTP/1.0 proxies like Squid.
.header("User-Agent", Version.userAgent())
.build();
内容来源于网络,如有侵权,请联系作者删除!