本文整理了Java中okhttp3.internal.Util.hostHeader()
方法的一些代码示例,展示了Util.hostHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.hostHeader()
方法的具体详情如下:
包路径:okhttp3.internal.Util
类名称:Util
方法名:hostHeader
暂无
代码示例来源:origin: square/okhttp
requestBuilder.header("Host", hostHeader(userRequest.url(), false));
代码示例来源:origin: square/okhttp
.url(route.address().url())
.method("CONNECT", null)
.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())
代码示例来源:origin: square/okhttp
HttpUrl url) throws IOException {
String requestLine = "CONNECT " + Util.hostHeader(url, true) + " HTTP/1.1";
while (true) {
Http1Codec tunnelConnection = new Http1Codec(null, null, source, sink);
代码示例来源:origin: com.squareup.okhttp3/okhttp
requestBuilder.header("Host", hostHeader(userRequest.url(), false));
代码示例来源:origin: com.squareup.okhttp3/okhttp
.url(route.address().url())
.method("CONNECT", null)
.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())
代码示例来源:origin: com.squareup.okhttp3/okhttp
HttpUrl url) throws IOException {
String requestLine = "CONNECT " + Util.hostHeader(url, true) + " HTTP/1.1";
while (true) {
Http1Codec tunnelConnection = new Http1Codec(null, null, source, sink);
代码示例来源: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: 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: 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: huxq17/SwipeCardsView
public static List<Header> http2HeadersList(Request request) {
Headers headers = request.headers();
List<Header> result = new ArrayList<>(headers.size() + 4);
result.add(new Header(TARGET_METHOD, request.method()));
result.add(new Header(TARGET_PATH, RequestLine.requestPath(request.url())));
result.add(new Header(TARGET_AUTHORITY, Util.hostHeader(request.url()))); // Optional.
result.add(new Header(TARGET_SCHEME, request.url().scheme()));
for (int i = 0, size = headers.size(); i < size; i++) {
// header names must be lowercase.
ByteString name = ByteString.encodeUtf8(headers.name(i).toLowerCase(Locale.US));
if (!HTTP_2_SKIPPED_REQUEST_HEADERS.contains(name)) {
result.add(new Header(name, headers.value(i)));
}
}
return result;
}
代码示例来源:origin: huxq17/tractor
public static List<Header> http2HeadersList(Request request) {
Headers headers = request.headers();
List<Header> result = new ArrayList<>(headers.size() + 4);
result.add(new Header(TARGET_METHOD, request.method()));
result.add(new Header(TARGET_PATH, RequestLine.requestPath(request.url())));
result.add(new Header(TARGET_AUTHORITY, Util.hostHeader(request.url()))); // Optional.
result.add(new Header(TARGET_SCHEME, request.url().scheme()));
for (int i = 0, size = headers.size(); i < size; i++) {
// header names must be lowercase.
ByteString name = ByteString.encodeUtf8(headers.name(i).toLowerCase(Locale.US));
if (!HTTP_2_SKIPPED_REQUEST_HEADERS.contains(name)) {
result.add(new Header(name, headers.value(i)));
}
}
return result;
}
代码示例来源:origin: duzechao/OKHttpUtils
public static List<Header> http2HeadersList(Request request) {
Headers headers = request.headers();
List<Header> result = new ArrayList<>(headers.size() + 4);
result.add(new Header(TARGET_METHOD, request.method()));
result.add(new Header(TARGET_PATH, RequestLine.requestPath(request.url())));
result.add(new Header(TARGET_AUTHORITY, Util.hostHeader(request.url()))); // Optional.
result.add(new Header(TARGET_SCHEME, request.url().scheme()));
for (int i = 0, size = headers.size(); i < size; i++) {
// header names must be lowercase.
ByteString name = ByteString.encodeUtf8(headers.name(i).toLowerCase(Locale.US));
if (!HTTP_2_SKIPPED_REQUEST_HEADERS.contains(name)) {
result.add(new Header(name, headers.value(i)));
}
}
return result;
}
代码示例来源: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: duzechao/OKHttpUtils
result.add(new Header(TARGET_PATH, RequestLine.requestPath(request.url())));
result.add(new Header(VERSION, "HTTP/1.1"));
result.add(new Header(TARGET_HOST, Util.hostHeader(request.url())));
result.add(new Header(TARGET_SCHEME, request.url().scheme()));
代码示例来源:origin: huxq17/tractor
result.add(new Header(TARGET_PATH, RequestLine.requestPath(request.url())));
result.add(new Header(VERSION, "HTTP/1.1"));
result.add(new Header(TARGET_HOST, Util.hostHeader(request.url())));
result.add(new Header(TARGET_SCHEME, request.url().scheme()));
代码示例来源:origin: huxq17/SwipeCardsView
result.add(new Header(TARGET_PATH, RequestLine.requestPath(request.url())));
result.add(new Header(VERSION, "HTTP/1.1"));
result.add(new Header(TARGET_HOST, Util.hostHeader(request.url())));
result.add(new Header(TARGET_SCHEME, request.url().scheme()));
代码示例来源:origin: huxq17/SwipeCardsView
result.header("Host", hostHeader(request.url()));
代码示例来源:origin: huxq17/tractor
result.header("Host", hostHeader(request.url()));
代码示例来源:origin: apache/servicemix-bundles
.url(route.address().url())
.method("CONNECT", null)
.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())
内容来源于网络,如有侵权,请联系作者删除!