Java Code Examples for com.squareup.okhttp.internal.http.RawHeaders#setRequestLine()

The following examples show how to use com.squareup.okhttp.internal.http.RawHeaders#setRequestLine() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TunnelRequest.java    From L.TileLayer.Cordova with MIT License 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 2
Source File: TunnelRequest.java    From IoTgo_Android_App with MIT License 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 3
Source File: TunnelRequest.java    From android-discourse with Apache License 2.0 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
    RawHeaders result = new RawHeaders();
    result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

    // Always set Host and User-Agent.
    result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
    result.set("User-Agent", userAgent);

    // Copy over the Proxy-Authorization header if it exists.
    if (proxyAuthorization != null) {
        result.set("Proxy-Authorization", proxyAuthorization);
    }

    // Always set the Proxy-Connection to Keep-Alive for the benefit of
    // HTTP/1.0 proxies like Squid.
    result.set("Proxy-Connection", "Keep-Alive");
    return result;
}
 
Example 4
Source File: TunnelRequest.java    From bluemix-parking-meter with MIT License 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 5
Source File: TunnelRequest.java    From reader with MIT License 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 6
Source File: TunnelRequest.java    From reader with MIT License 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 7
Source File: TunnelRequest.java    From cordova-amazon-fireos with Apache License 2.0 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 8
Source File: TunnelRequest.java    From phonegapbootcampsite with MIT License 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 9
Source File: TunnelRequest.java    From CordovaYoutubeVideoPlayer with MIT License 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 10
Source File: TunnelRequest.java    From cordova-android-chromeview with Apache License 2.0 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 11
Source File: TunnelRequest.java    From wildfly-samples with MIT License 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 12
Source File: TunnelRequest.java    From phonegap-plugin-loading-spinner with Apache License 2.0 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}
 
Example 13
Source File: TunnelRequest.java    From crosswalk-cordova-android with Apache License 2.0 6 votes vote down vote up
/**
 * If we're creating a TLS tunnel, send only the minimum set of headers.
 * This avoids sending potentially sensitive data like HTTP cookies to
 * the proxy unencrypted.
 */
RawHeaders getRequestHeaders() {
  RawHeaders result = new RawHeaders();
  result.setRequestLine("CONNECT " + host + ":" + port + " HTTP/1.1");

  // Always set Host and User-Agent.
  result.set("Host", port == getDefaultPort("https") ? host : (host + ":" + port));
  result.set("User-Agent", userAgent);

  // Copy over the Proxy-Authorization header if it exists.
  if (proxyAuthorization != null) {
    result.set("Proxy-Authorization", proxyAuthorization);
  }

  // Always set the Proxy-Connection to Keep-Alive for the benefit of
  // HTTP/1.0 proxies like Squid.
  result.set("Proxy-Connection", "Keep-Alive");
  return result;
}