当前位置: 首页>>代码示例>>Java>>正文


Java Protocol.HTTP_1_0属性代码示例

本文整理汇总了Java中com.squareup.okhttp.Protocol.HTTP_1_0属性的典型用法代码示例。如果您正苦于以下问题:Java Protocol.HTTP_1_0属性的具体用法?Java Protocol.HTTP_1_0怎么用?Java Protocol.HTTP_1_0使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.squareup.okhttp.Protocol的用法示例。


在下文中一共展示了Protocol.HTTP_1_0属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

public static StatusLine parse(String statusLine) throws IOException {
    int codeStart;
    Protocol protocol;
    if (statusLine.startsWith("HTTP/1.")) {
        if (statusLine.length() < 9 || statusLine.charAt(8) != ' ') {
            throw new ProtocolException("Unexpected status line: " + statusLine);
        }
        int httpMinorVersion = statusLine.charAt(7) - 48;
        codeStart = 9;
        if (httpMinorVersion == 0) {
            protocol = Protocol.HTTP_1_0;
        } else if (httpMinorVersion == 1) {
            protocol = Protocol.HTTP_1_1;
        } else {
            throw new ProtocolException("Unexpected status line: " + statusLine);
        }
    } else if (statusLine.startsWith("ICY ")) {
        protocol = Protocol.HTTP_1_0;
        codeStart = 4;
    } else {
        throw new ProtocolException("Unexpected status line: " + statusLine);
    }
    if (statusLine.length() < codeStart + 3) {
        throw new ProtocolException("Unexpected status line: " + statusLine);
    }
    try {
        int code = Integer.parseInt(statusLine.substring(codeStart, codeStart + 3));
        String message = "";
        if (statusLine.length() > codeStart + 3) {
            if (statusLine.charAt(codeStart + 3) != ' ') {
                throw new ProtocolException("Unexpected status line: " + statusLine);
            }
            message = statusLine.substring(codeStart + 4);
        }
        return new StatusLine(protocol, code, message);
    } catch (NumberFormatException e) {
        throw new ProtocolException("Unexpected status line: " + statusLine);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:39,代码来源:StatusLine.java

示例2: concatLengthPrefixed

static byte[] concatLengthPrefixed(List<Protocol> protocols) {
    Buffer result = new Buffer();
    int size = protocols.size();
    for (int i = 0; i < size; i++) {
        Protocol protocol = (Protocol) protocols.get(i);
        if (protocol != Protocol.HTTP_1_0) {
            result.writeByte(protocol.toString().length());
            result.writeUtf8(protocol.toString());
        }
    }
    return result.readByteArray();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:Platform.java

示例3: toString

public final String toString()
{
  StringBuilder localStringBuilder = new StringBuilder();
  if (this.protocol == Protocol.HTTP_1_0) {}
  for (String str = "HTTP/1.0";; str = "HTTP/1.1")
  {
    localStringBuilder.append(str);
    localStringBuilder.append(' ').append(this.code);
    if (this.message != null) {
      localStringBuilder.append(' ').append(this.message);
    }
    return localStringBuilder.toString();
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:14,代码来源:StatusLine.java

示例4: version

public static String version(Protocol paramProtocol)
{
  if (paramProtocol == Protocol.HTTP_1_0) {
    return "HTTP/1.0";
  }
  return "HTTP/1.1";
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:7,代码来源:RequestLine.java

示例5: configureTlsExtensions

public final void configureTlsExtensions(SSLSocket paramSSLSocket, String paramString, List<Protocol> paramList)
{
  if (paramString != null)
  {
    OptionalMethod localOptionalMethod = SET_USE_SESSION_TICKETS;
    Object[] arrayOfObject2 = new Object[1];
    arrayOfObject2[0] = Boolean.valueOf(true);
    localOptionalMethod.invokeOptionalWithoutCheckedException(paramSSLSocket, arrayOfObject2);
    SET_HOSTNAME.invokeOptionalWithoutCheckedException(paramSSLSocket, new Object[] { paramString });
  }
  boolean bool1 = SET_NPN_PROTOCOLS.isSupported(paramSSLSocket);
  boolean bool2 = SET_ALPN_PROTOCOLS.isSupported(paramSSLSocket);
  if ((!bool1) && (!bool2)) {}
  Object[] arrayOfObject1;
  do
  {
    return;
    arrayOfObject1 = new Object[1];
    Buffer localBuffer = new Buffer();
    int i = paramList.size();
    for (int j = 0; j < i; j++)
    {
      Protocol localProtocol = (Protocol)paramList.get(j);
      if (localProtocol != Protocol.HTTP_1_0)
      {
        localBuffer.writeByte(localProtocol.toString().length());
        localBuffer.writeUtf8(localProtocol.toString());
      }
    }
    arrayOfObject1[0] = localBuffer.readByteArray();
    if (bool1) {
      SET_NPN_PROTOCOLS.invokeWithoutCheckedException(paramSSLSocket, arrayOfObject1);
    }
  } while (!bool2);
  SET_ALPN_PROTOCOLS.invokeWithoutCheckedException(paramSSLSocket, arrayOfObject1);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:36,代码来源:Platform.java

示例6: networkRequest

/**
 * 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 ((connection == null || connection.getProtocol() != Protocol.HTTP_1_0)
      && request.header("Connection") == null) {
    result.header("Connection", "Keep-Alive");
  }

  if (request.header("Accept-Encoding") == null) {
    transparentGzip = true;
    result.header("Accept-Encoding", "gzip");
  }

  CookieHandler cookieHandler = client.getCookieHandler();
  if (cookieHandler != null) {
    // Capture the request headers added so far so that they can be offered to the CookieHandler.
    // This is mostly to stay close to the RI; it is unlikely any of the headers above would
    // affect cookie choice besides "Host".
    Map<String, List<String>> headers = OkHeaders.toMultimap(result.build().headers(), null);

    Map<String, List<String>> cookies = cookieHandler.get(request.uri(), headers);

    // Add any new cookies to the request.
    OkHeaders.addCookies(result, cookies);
  }

  return result.build();
}
 
开发者ID:NannanZ,项目名称:spdymcsclient,代码行数:38,代码来源:HttpEngine.java

示例7: concatLengthPrefixed

/**
 * Returns the concatenation of 8-bit, length prefixed protocol names.
 * http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04#page-4
 */
static byte[] concatLengthPrefixed(List<Protocol> protocols) {
  Buffer result = new Buffer();
  for (int i = 0, size = protocols.size(); i < size; i++) {
    Protocol protocol = protocols.get(i);
    if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for NPN.
    result.writeByte(protocol.toString().length());
    result.writeUtf8(protocol.toString());
  }
  return result.readByteArray();
}
 
开发者ID:NannanZ,项目名称:spdymcsclient,代码行数:14,代码来源:Platform.java

示例8: parse

public static StatusLine parse(String statusLine) throws IOException {
  // H T T P / 1 . 1   2 0 0   T e m p o r a r y   R e d i r e c t
  // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0

  // Parse protocol like "HTTP/1.1" followed by a space.
  int codeStart;
  Protocol protocol;
  if (statusLine.startsWith("HTTP/1.")) {
    if (statusLine.length() < 9 || statusLine.charAt(8) != ' ') {
      throw new ProtocolException("Unexpected status line: " + statusLine);
    }
    int httpMinorVersion = statusLine.charAt(7) - '0';
    codeStart = 9;
    if (httpMinorVersion == 0) {
      protocol = Protocol.HTTP_1_0;
    } else if (httpMinorVersion == 1) {
      protocol = Protocol.HTTP_1_1;
    } else {
      throw new ProtocolException("Unexpected status line: " + statusLine);
    }
  } else if (statusLine.startsWith("ICY ")) {
    // Shoutcast uses ICY instead of "HTTP/1.0".
    protocol = Protocol.HTTP_1_0;
    codeStart = 4;
  } else {
    throw new ProtocolException("Unexpected status line: " + statusLine);
  }

  // Parse response code like "200". Always 3 digits.
  if (statusLine.length() < codeStart + 3) {
    throw new ProtocolException("Unexpected status line: " + statusLine);
  }
  int code;
  try {
    code = Integer.parseInt(statusLine.substring(codeStart, codeStart + 3));
  } catch (NumberFormatException e) {
    throw new ProtocolException("Unexpected status line: " + statusLine);
  }

  // Parse an optional response message like "OK" or "Not Modified". If it
  // exists, it is separated from the response code by a space.
  String message = "";
  if (statusLine.length() > codeStart + 3) {
    if (statusLine.charAt(codeStart + 3) != ' ') {
      throw new ProtocolException("Unexpected status line: " + statusLine);
    }
    message = statusLine.substring(codeStart + 4);
  }

  return new StatusLine(protocol, code, message);
}
 
开发者ID:NannanZ,项目名称:spdymcsclient,代码行数:51,代码来源:StatusLine.java

示例9: version

public static String version(Protocol protocol) {
  return protocol == Protocol.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1";
}
 
开发者ID:NannanZ,项目名称:spdymcsclient,代码行数:3,代码来源:RequestLine.java


注:本文中的com.squareup.okhttp.Protocol.HTTP_1_0属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。