コード例 #1
0
ファイル: Http2ConnectionTest.java プロジェクト: LYDXY/okhttp
 private FramedConnection.Builder connectionBuilder(MockSpdyPeer peer, Variant variant)
     throws IOException {
   return new FramedConnection.Builder(true)
       .socket(peer.openSocket())
       .pushObserver(IGNORE)
       .protocol(variant.getProtocol());
 }
コード例 #2
0
ファイル: Http2ConnectionTest.java プロジェクト: LYDXY/okhttp
  /**
   * When writing a set of headers fails due to an {@code IOException}, make sure the writer is left
   * in a consistent state so the next writer also gets an {@code IOException} also instead of
   * something worse (like an {@link IllegalStateException}.
   *
   * <p>See https://github.com/square/okhttp/issues/1651
   */
  @Test
  public void socketExceptionWhileWritingHeaders() throws Exception {
    peer.setVariantAndClient(HTTP_2, false);
    peer.acceptFrame(); // SYN_STREAM.
    peer.play();

    String longString = repeat('a', Http2.INITIAL_MAX_FRAME_SIZE + 1);
    Socket socket = peer.openSocket();
    FramedConnection connection =
        new FramedConnection.Builder(true)
            .socket(socket)
            .pushObserver(IGNORE)
            .protocol(HTTP_2.getProtocol())
            .build();
    socket.shutdownOutput();
    try {
      connection.newStream(headerEntries("a", longString), false, true);
      fail();
    } catch (IOException expected) {
    }
    try {
      connection.newStream(headerEntries("b", longString), false, true);
      fail();
    } catch (IOException expected) {
    }
  }