com.squareup.okhttp.internal.http.RawHeaders#addLine ( )源码实例Demo

下面列出了com.squareup.okhttp.internal.http.RawHeaders#addLine ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: L.TileLayer.Cordova   文件: HttpResponseCache.java
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
源代码2 项目: IoTgo_Android_App   文件: HttpResponseCache.java
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
源代码3 项目: android-discourse   文件: HttpResponseCache.java
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 * <p/>
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * <p/>
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 * <p/>
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 * <p/>
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
    try {
        StrictLineReader reader = new StrictLineReader(in, US_ASCII);
        uri = reader.readLine();
        requestMethod = reader.readLine();
        varyHeaders = new RawHeaders();
        int varyRequestHeaderLineCount = reader.readInt();
        for (int i = 0; i < varyRequestHeaderLineCount; i++) {
            varyHeaders.addLine(reader.readLine());
        }

        responseHeaders = new RawHeaders();
        responseHeaders.setStatusLine(reader.readLine());
        int responseHeaderLineCount = reader.readInt();
        for (int i = 0; i < responseHeaderLineCount; i++) {
            responseHeaders.addLine(reader.readLine());
        }

        if (isHttps()) {
            String blank = reader.readLine();
            if (blank.length() > 0) {
                throw new IOException("expected \"\" but was \"" + blank + "\"");
            }
            cipherSuite = reader.readLine();
            peerCertificates = readCertArray(reader);
            localCertificates = readCertArray(reader);
        } else {
            cipherSuite = null;
            peerCertificates = null;
            localCertificates = null;
        }
    } finally {
        in.close();
    }
}
 
源代码4 项目: bluemix-parking-meter   文件: HttpResponseCache.java
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
源代码5 项目: reader   文件: HttpResponseCache.java
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
源代码6 项目: reader   文件: HttpResponseCache.java
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
源代码7 项目: cordova-amazon-fireos   文件: HttpResponseCache.java
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
源代码8 项目: phonegapbootcampsite   文件: HttpResponseCache.java
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
源代码11 项目: wildfly-samples   文件: HttpResponseCache.java
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}
 
/**
 * Reads an entry from an input stream. A typical entry looks like this:
 * <pre>{@code
 *   http://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 * }</pre>
 *
 * <p>A typical HTTPS file looks like this:
 * <pre>{@code
 *   https://google.com/foo
 *   GET
 *   2
 *   Accept-Language: fr-CA
 *   Accept-Charset: UTF-8
 *   HTTP/1.1 200 OK
 *   3
 *   Content-Type: image/png
 *   Content-Length: 100
 *   Cache-Control: max-age=600
 *
 *   AES_256_WITH_MD5
 *   2
 *   base64-encoded peerCertificate[0]
 *   base64-encoded peerCertificate[1]
 *   -1
 * }</pre>
 * The file is newline separated. The first two lines are the URL and
 * the request method. Next is the number of HTTP Vary request header
 * lines, followed by those lines.
 *
 * <p>Next is the response status line, followed by the number of HTTP
 * response header lines, followed by those lines.
 *
 * <p>HTTPS responses also contain SSL session information. This begins
 * with a blank line, and then a line containing the cipher suite. Next
 * is the length of the peer certificate chain. These certificates are
 * base64-encoded and appear each on their own line. The next line
 * contains the length of the local certificate chain. These
 * certificates are also base64-encoded and appear each on their own
 * line. A length of -1 is used to encode a null array.
 */
public Entry(InputStream in) throws IOException {
  try {
    StrictLineReader reader = new StrictLineReader(in, US_ASCII);
    uri = reader.readLine();
    requestMethod = reader.readLine();
    varyHeaders = new RawHeaders();
    int varyRequestHeaderLineCount = reader.readInt();
    for (int i = 0; i < varyRequestHeaderLineCount; i++) {
      varyHeaders.addLine(reader.readLine());
    }

    responseHeaders = new RawHeaders();
    responseHeaders.setStatusLine(reader.readLine());
    int responseHeaderLineCount = reader.readInt();
    for (int i = 0; i < responseHeaderLineCount; i++) {
      responseHeaders.addLine(reader.readLine());
    }

    if (isHttps()) {
      String blank = reader.readLine();
      if (blank.length() > 0) {
        throw new IOException("expected \"\" but was \"" + blank + "\"");
      }
      cipherSuite = reader.readLine();
      peerCertificates = readCertArray(reader);
      localCertificates = readCertArray(reader);
    } else {
      cipherSuite = null;
      peerCertificates = null;
      localCertificates = null;
    }
  } finally {
    in.close();
  }
}