@Test
  public void testHttpHeaderSize() throws Exception {
    // Stop HiveServer2
    stopMiniHS2();
    HiveConf conf = getNewHiveConf();
    conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_HTTP_REQUEST_HEADER_SIZE, 1024);
    conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_HTTP_RESPONSE_HEADER_SIZE, 1024);
    startMiniHS2(conf, true);

    // Username and password are added to the http request header.
    // We will test the reconfiguration of the header size by changing the password length.
    String userName = "userName";
    String password = StringUtils.leftPad("*", 100);
    Connection conn = null;
    // This should go fine, since header should be less than the configured header size
    try {
      conn = getConnection(miniHS2.getJdbcURL(testDbName), userName, password);
    } catch (Exception e) {
      fail("Not expecting exception: " + e);
    } finally {
      if (conn != null) {
        conn.close();
      }
    }

    // This should fail with given HTTP response code 431 in error message, since header is more
    // than the configured the header size
    password = StringUtils.leftPad("*", 2000);
    Exception headerException = null;
    try {
      conn = null;
      conn = getConnection(miniHS2.getJdbcURL(testDbName), userName, password);
    } catch (Exception e) {
      headerException = e;
    } finally {
      if (conn != null) {
        conn.close();
      }

      assertTrue("Header exception should be thrown", headerException != null);
      assertTrue("Incorrect HTTP Response:" + headerException.getMessage(),
          headerException.getMessage().contains("HTTP Response code: 431"));
    }

    // Stop HiveServer2 to increase header size
    stopMiniHS2();
    conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_HTTP_REQUEST_HEADER_SIZE, 3000);
    conf.setIntVar(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_HTTP_RESPONSE_HEADER_SIZE, 3000);
    startMiniHS2(conf);

    // This should now go fine, since we increased the configured header size
    try {
      conn = null;
      conn = getConnection(miniHS2.getJdbcURL(testDbName), userName, password);
    } catch (Exception e) {
      fail("Not expecting exception: " + e);
    } finally {
      if (conn != null) {
        conn.close();
      }
    }

    // Restore original state
    restoreMiniHS2AndConnections();
  }
Test for http header size
@throws Exception
itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestJdbcWithMiniHS2.java