test_class.file: http-client/src/test/java/com/alibaba/csb/sdk/CmdHttpCallerTest.java
test_class.identifier: CmdHttpCallerTest
test_class.superclass: extends TestCase
test_case.body: @Test
      public void testCGet() {
          CmdHttpCaller.main(new String[]{"-url", "http://abc:123?a=b&c=abc",
                  "-api", "aaa",
                  "-version", "1.0.0",
                  "-method", "cget",
                  "-ak", "ak",
                  "-sk", "sk",
                  "-H", "name1:abc1",
                  "-D", "param1=value1",
                  "-sign", "com.alibaba.csb.sdk.SampleSignImpl",
                  "-verify", "com.alibaba.aosp.extension.security.SampleVerifySignImpl",
                  "-nonce"});
      }
test_case.class_method_signature: CmdHttpCallerTest.testCGet()
test_case.full_signature: @Test public void testCGet()
test_case.identifier: testCGet
test_case.invocations: main
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testCGet()
focal_class.declarator: SDK_VERSION = "1.1.5.8"
focal_class.modifier: private static final
focal_class.original_string: private static final String SDK_VERSION = "1.1.5.8";
focal_class.type: String
focal_class.var_name: SDK_VERSION
focal_class.declarator: opt = new Options()
focal_class.modifier: public static
focal_class.original_string: public static Options opt = new Options();
focal_class.type: Options
focal_class.var_name: opt
focal_class.file: http-client/src/main/java/com/alibaba/csb/sdk/CmdHttpCaller.java
focal_class.identifier: CmdHttpCaller
focal_class.class_method_signature: CmdHttpCaller.isEmpty(String str)
focal_class.full_signature: private static boolean isEmpty(String str)
focal_class.identifier: isEmpty
focal_class.modifiers: private static
focal_class.parameters: (String str)
focal_class.return: boolean
focal_class.signature: boolean isEmpty(String str)
focal_class.class_method_signature: CmdHttpCaller.main(String[] args)
focal_class.full_signature: public static void main(String[] args)
focal_class.identifier: main
focal_class.modifiers: public static
focal_class.parameters: (String[] args)
focal_class.return: void
focal_class.signature: void main(String[] args)
focal_class.class_method_signature: CmdHttpCaller.printKV(String title, String[] kvs)
focal_class.full_signature: private static void printKV(String title, String[] kvs)
focal_class.identifier: printKV
focal_class.modifiers: private static
focal_class.parameters: (String title, String[] kvs)
focal_class.return: void
focal_class.signature: void printKV(String title, String[] kvs)
focal_class.class_method_signature: CmdHttpCaller.usage(String message)
focal_class.full_signature: static void usage(String message)
focal_class.identifier: usage
focal_class.modifiers: static
focal_class.parameters: (String message)
focal_class.return: void
focal_class.signature: void usage(String message)
focal_method.body: public static void main(String[] args) {
          CommandLineParser parser = new DefaultParser();
  
          Boolean isDebug = false;
          try {
              CommandLine commandline = parser.parse(opt, args);
              if (commandline.getOptions().length == 0 && commandline.getArgs().length > 0) {
                  //use old style cmd line
                  CmdCaller.main(args);
                  return;
              }
              if (commandline.hasOption("h")) {
                  usage(null);
                  return;
              }
  
              String ak = commandline.getOptionValue("ak");
              String sk = commandline.getOptionValue("sk");
              String api = commandline.getOptionValue("api");
              String version = commandline.getOptionValue("version");
              Boolean sdkv = commandline.hasOption("sdkv");
              String method = commandline.getOptionValue("method");
              String[] headers = commandline.getOptionValues("H");
              String[] params = commandline.getOptionValues("D");
              String url = commandline.getOptionValue("url");
              String proxy = commandline.getOptionValue("proxy");
              String cbJSON = commandline.getOptionValue("cbJSON");
              boolean nonce = commandline.hasOption("nonce");
              String bizIdKey = commandline.getOptionValue("bizIdKey");
              String bizId = commandline.getOptionValue("bizId");
              isDebug = commandline.hasOption("d");
  
              if (sdkv) {
                  Version.version();
                  return;
              }
  
              String signImpl = commandline.getOptionValue("sign");
              String verifySignImpl = commandline.getOptionValue("verify");
  
              if (isDebug) {
                  System.out.println("url=" + url);
                  System.out.println("api=" + api);
                  System.out.println("version=" + version);
                  System.out.println("bizIdKey=" + bizIdKey);
                  System.out.println("bizId=" + bizId);
                  System.out.println("ak=" + ak);
                  System.out.println("sk=" + sk);
                  System.out.println("proxy=" + proxy);
                  System.out.println("nonce=" + nonce);
                  System.out.println("signImpl=" + signImpl);
                  System.out.println("verifySignImpl=" + verifySignImpl);
                  printKV("HTTP Headers", headers);
                  printKV("HTTP Params", params);
              }
  
              if (isEmpty(api)) {
                  usage(MessageHelper.getMessage("cli.defparam", "-api"));
                  return;
              }
  
              if (isEmpty(version)) {
                  usage(MessageHelper.getMessage("cli.defparam", "-version"));
                  return;
              }
  
              if (isEmpty(url)) {
                  usage(MessageHelper.getMessage("cli.defparam", "-url"));
                  return;
              }
  
              if (method == null) {
                  method = "get";
              }
              HttpParameters.Builder builder = HttpParameters.newBuilder();
              if (bizIdKey != null && !bizIdKey.trim().equals("")) {
                  HttpCaller.bizIdKey(bizIdKey);
              }
              builder.api(api).version(version).method(method).bizId(bizId).requestURL(url).accessKey(ak).secretKey(sk).signImpl(signImpl).verifySignImpl(verifySignImpl);
  
              if (headers != null) {
                  for (String header : headers) {
                      String[] kv = header.split(":", 2);
                      if (kv == null || kv.length != 2) {
                          System.out.println("" + header);
                          return;
                      }
                      builder.putHeaderParamsMap(kv[0], kv[1]);
                  }
              }
  
              if (params != null) {
                  for (String param : params) {
                      String[] kv = param.split("=", 2);
                      if (kv == null || kv.length != 2) {
                          System.out.println(MessageHelper.getMessage("cli.defh", param));
                          return;
                      }
                      builder.putParamsMap(kv[0], kv[1]);
                  }
              }
  
              if (cbJSON != null) {
                  if ("cget".equalsIgnoreCase(method) || "get".equalsIgnoreCase(method)) {
                      System.out.println(MessageHelper.getMessage("cli.defpost"));
                      return;
                  }
                  if (cbJSON.startsWith("'")) {
                      System.out.println(MessageHelper.getMessage("cli.json.prefix"));
                      return;
                  }
                  builder.contentBody(new ContentBody(cbJSON));
              }
  
              builder.nonce(nonce);
  
              if (isDebug) {
                  builder.diagnostic(true); //打印诊断信息
              }
  
              boolean curlOnly = false;
              if (method.toLowerCase().startsWith("c")) {
                  curlOnly = true;
                  HttpCaller.setCurlResponse(true);
              }
  
              StringBuffer resHttpHeaders = new StringBuffer();
              //set http proxy
              if (proxy != null) {
                  String errMsg = MessageHelper.getMessage("cli.errproxy", proxy);
                  String[] pcs = proxy.split(":");
                  if (pcs == null || pcs.length != 2) {
                      System.out.println(errMsg);
                      return;
                  }
                  try {
                      HttpCaller.setProxyHost(pcs[0], Integer.parseInt(pcs[1]), null);
                  } catch (Exception e) {
                      System.out.println(errMsg);
                      return;
                  }
              }
  
              HttpReturn ret = HttpCaller.invokeReturn(builder.build());
  
              if (curlOnly) {
                  System.out.println("---- curlString = " + ret.getResponseStr());
              } else {
                  if (isDebug) {
                      System.out.println("Diagnostic Info:" + ret.diagnosticInfo);
                  }
                  System.out.println("---- response http headers = " + ret.responseHeaders);
                  System.out.println("---- retStr = " + ret.getResponseStr());
  
                  //call multi-times for stress or flow-ctrl testing
                  int times = Integer.getInteger("test.stress.times", 0);
                  for (int i = 2; i <= times; i++) {
                      ret = HttpCaller.invokeReturn(builder.build());
                      System.out.println("---- retStr [#" + i + "] = " + ret.getResponseStr());
                  }
              }
          } catch (Exception e) {
              System.out.println("-- operation error：" + e.getMessage());
              //if (isDebug)
              e.printStackTrace(System.out);
          }
      }
focal_method.class_method_signature: CmdHttpCaller.main(String[] args)
focal_method.full_signature: public static void main(String[] args)
focal_method.identifier: main
focal_method.invocations: parse getOptions getArgs main hasOption usage getOptionValue getOptionValue getOptionValue getOptionValue hasOption getOptionValue getOptionValues getOptionValues getOptionValue getOptionValue getOptionValue hasOption getOptionValue getOptionValue hasOption version getOptionValue getOptionValue println println println println println println println println println println println printKV printKV isEmpty usage getMessage isEmpty usage getMessage isEmpty usage getMessage newBuilder equals trim bizIdKey verifySignImpl signImpl secretKey accessKey requestURL bizId method version api split println putHeaderParamsMap split println getMessage putParamsMap equalsIgnoreCase equalsIgnoreCase println getMessage startsWith println getMessage contentBody nonce diagnostic startsWith toLowerCase setCurlResponse getMessage split println setProxyHost parseInt println invokeReturn build println getResponseStr println println println getResponseStr getInteger invokeReturn build println getResponseStr println tMessage() printStackTrace
focal_method.modifiers: public static
focal_method.parameters: (String[] args)
focal_method.return: void
focal_method.signature: void main(String[] args)