CLI构建http request

 private static Request buildQueryRequest(ClientSession session, String query)

    { //看到这里了

        Request.Builder builder = preparePost()

                .setUri(uriBuilderFrom(session.getServer()).replacePath("/v1/statement").build())

                .setBodyGenerator(createStaticBodyGenerator(queryUTF_8));

 

        if (session.getUser() != null) {

            builder.setHeader(PrestoHeaders.PRESTO_USERsession.getUser());

        }

        if (session.getSource() != null) {

            builder.setHeader(PrestoHeaders.PRESTO_SOURCEsession.getSource());

        }

        if (session.getCatalog() != null) {

            builder.setHeader(PrestoHeaders.PRESTO_CATALOGsession.getCatalog());

        }

        if (session.getSchema() != null) {

            builder.setHeader(PrestoHeaders.PRESTO_SCHEMAsession.getSchema());

        }

        builder.setHeader(PrestoHeaders.PRESTO_TIME_ZONEsession.getTimeZoneId());

        builder.setHeader(PrestoHeaders.PRESTO_LANGUAGEsession.getLocale().toLanguageTag());

        builder.setHeader(USER_AGENTUSER_AGENT_VALUE);

 

        Map<String, String> property = session.getProperties();

        for (Entry<String, String> entry : property.entrySet()) {

            builder.addHeader(PrestoHeaders.PRESTO_SESSIONentry.getKey() + "=" + entry.getValue());

        }

 

        builder.setHeader(PrestoHeaders.PRESTO_TRANSACTION_IDsession.getTransactionId() == null ? "NONE" : session.getTransactionId());

 

        return builder.build();

    }

这段代码是构造HTTP请求的,下面解释具体做了哪些事情!

===通过抓包,截图如下:

CLI构建http request_第1张图片


你可能感兴趣的:(impala,presto)