如何在养蜂场的降价显示可选标题?

时间:2016-01-04 09:03:22

标签: apiary.io

如何通过养蜂场的降价来表明请求的一个特定标题是可选的?

我的代码:

  • 请求
    apiKey可以在标题中传递(注意来自" apiKey&#34的camelcase)。 Content-Encoding:gzip是可选的,仅当你gzip实体

    • 接头

      @Override
      protected Void doInBackground(Void... params){
          // Create a trust manager that does not validate certificate chains
          TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
              public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                  return null;
              }
      
              public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
              }
      
              public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
              }
          } };
      
          // Install the all-trusting trust manager
          try {
              SSLContext sc = SSLContext.getInstance("SSL");
              sc.init(null, trustAllCerts, new java.security.SecureRandom());
              HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
          } catch (Exception e) {
              throw new RuntimeException(e);
          }
      
          // Your code ...
          URL url = null;
          HttpsURLConnection conn = null;
          try {
            url = new URL("https://example.com");
          } catch (MalformedURLException e) {
            e.printStackTrace();
          }
      
          // ...
      }
      

以上是否可以?

1 个答案:

答案 0 :(得分:7)

截至2016年1月,不可能

另一方面 - 如果你转到API Blueprint Roadmap,那里的MSON Parameters and Headers功能目前处于RFC阶段;这将使您能够使用MSON语法描述HTTP标头,并将每个HTTP标头标记为必需/可选(见下文)。

+ Response 200 (application/json)
    + Headers
        + Date (Date, optional) - Date at which the message was originated

希望MSON Headers即将登陆。