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(); } } }
private String defaultUserAgent() { String agent = Util.getSystemProperty("http.agent", null); return agent != null ? toHumanReadableAscii(agent) : Version.userAgent(); }
requestBuilder.header("User-Agent", Version.userAgent());
.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();
requestBuilder.header("User-Agent", Version.userAgent());
.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();
private void addUserAgentHeader(OkHttpRestfulRequest theHttpRequest, FhirContext theContext) { theHttpRequest.addHeader("User-Agent", HttpClientUtil.createUserAgentString(theContext, Version.userAgent())); }
@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); } } }
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; }
private String defaultUserAgent() { String agent = System.getProperty("http.agent"); return agent != null ? Util.toHumanReadableAscii(agent) : Version.userAgent(); }
private String defaultUserAgent() { String agent = System.getProperty("http.agent"); return agent != null ? toHumanReadableAscii(agent) : Version.userAgent(); }
private String defaultUserAgent() { String agent = Util.getSystemProperty("http.agent", null); return agent != null ? toHumanReadableAscii(agent) : Version.userAgent(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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; }
result.header("User-Agent", Version.userAgent());
result.header("User-Agent", Version.userAgent());
.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();