javax.net.ssl.HttpsURLConnection.setRequestMethod()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(253)

本文整理了Java中javax.net.ssl.HttpsURLConnection.setRequestMethod()方法的一些代码示例,展示了HttpsURLConnection.setRequestMethod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpsURLConnection.setRequestMethod()方法的具体详情如下:
包路径:javax.net.ssl.HttpsURLConnection
类名称:HttpsURLConnection
方法名:setRequestMethod

HttpsURLConnection.setRequestMethod介绍

暂无

代码示例

代码示例来源:origin: knowm/XChange

static ReturnCurrenciesResponse allCurrenciesStatic() throws IOException {
  HttpsURLConnection c =
    (HttpsURLConnection) new URL("https://api.idex.market/returnCurrencies").openConnection();
  c.setRequestMethod("POST");
  c.setRequestProperty("Accept-Encoding", "gzip");
  c.setRequestProperty("User-Agent", "irrelevant");
  try (InputStreamReader inputStreamReader =
    new InputStreamReader(new GZIPInputStream(c.getInputStream()))) {
   ObjectMapper objectMapper = new ObjectMapper();
   return objectMapper.readerFor(ReturnCurrenciesResponse.class).readValue(inputStreamReader);
  }
 }
}

代码示例来源:origin: knowm/XChange

/** same as curl -XPOST https://api.idex.market/returnTicker */
static ReturnTickerRequestedWithNull allTickersStatic() throws IOException {
 ReturnTickerRequestedWithNull o = null;
 javax.net.ssl.HttpsURLConnection c = null;
 c = (HttpsURLConnection) new URL("https://api.idex.market/returnTicker").openConnection();
 c.setRequestMethod("POST");
 c.setRequestProperty("Accept-Encoding", "gzip");
 c.setRequestProperty("User-Agent", "irrelevant");
 ObjectMapper objectMapper = new ObjectMapper();
 try (InputStream inputStream = c.getInputStream();
   GZIPInputStream in = new GZIPInputStream(inputStream);
   InputStreamReader inputStreamReader = new InputStreamReader(in)) {
  o =
    objectMapper
      .readerFor(ReturnTickerRequestedWithNull.class)
      .readValue(inputStreamReader);
 }
 return o;
}

代码示例来源:origin: knowm/XChange

HttpsURLConnection.setDefaultHostnameVerifier(hnv);
 HttpsURLConnection httpsUrlConn = (HttpsURLConnection) (new URL(serverUrl)).openConnection();
 httpsUrlConn.setRequestMethod("POST");
 conn = httpsUrlConn;
} else {

代码示例来源:origin: knowm/XChange

HttpsURLConnection.setDefaultHostnameVerifier(hnv);
 HttpsURLConnection httpsUrlConn = (HttpsURLConnection) (new URL(serverUrl)).openConnection();
 httpsUrlConn.setRequestMethod("POST");
 conn = httpsUrlConn;
} else {

代码示例来源:origin: jmdhappy/xxpay-master

conn.setDoInput(true);
conn.setUseCaches(false);
conn.setRequestMethod(requestMethod);
if (null != outputStr) {
  OutputStream outputStream = conn.getOutputStream();

代码示例来源:origin: jmdhappy/xxpay-master

conn.setDoInput(true);
conn.setUseCaches(false);
conn.setRequestMethod(requestMethod);
if (null != outputStr) {
  OutputStream outputStream = conn.getOutputStream();

代码示例来源:origin: jmdhappy/xxpay-master

HttpsURLConnection con = (HttpsURLConnection) console.openConnection();
con.setSSLSocketFactory(sc.getSocketFactory());
con.setRequestMethod("POST");
con.setDoInput(true);
con.setDoOutput(true);

代码示例来源:origin: Javen205/IJPay

conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);

代码示例来源:origin: Javen205/IJPay

conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);

代码示例来源:origin: GlowstoneMC/Glowstone

conn = (HttpsURLConnection) url.openConnection();
  conn.setDoOutput(true);
  conn.setRequestMethod("POST");
  conn.setRequestProperty("Content-Type", "application/json");
} catch (IOException e) {

代码示例来源:origin: jmdhappy/xxpay-master

HttpsURLConnection con = (HttpsURLConnection) console.openConnection();
con.setSSLSocketFactory(sc.getSocketFactory());
con.setRequestMethod("POST");
con.setDoInput(true);
con.setDoOutput(true);

代码示例来源:origin: jmdhappy/xxpay-master

HttpsURLConnection con = (HttpsURLConnection) console.openConnection();
con.setSSLSocketFactory(sc.getSocketFactory());
con.setRequestMethod("POST");
con.setDoInput(true);
con.setDoOutput(true);

代码示例来源:origin: wildfly/wildfly

if (connection instanceof HttpsURLConnection) {
  HttpsURLConnection conn = (HttpsURLConnection) connection;
  conn.setRequestMethod("GET");
  conn.setSSLSocketFactory(sslContext.getSocketFactory());
  conn.setHostnameVerifier(hostnameVerifier);

代码示例来源:origin: apache/nifi

@Override
  public void run() {
    try {
      final int port = ((HandleHttpRequest) runner.getProcessor()).getPort();
      final HttpsURLConnection connection = (HttpsURLConnection) new URL("https://localhost:"
          + port + "/my/path?query=true&value1=value1&value2=&value3&value4=apple=orange").openConnection();
      connection.setSSLSocketFactory(sslContext.getSocketFactory());
      connection.setDoOutput(false);
      connection.setRequestMethod("GET");
      connection.setRequestProperty("header1", "value1");
      connection.setRequestProperty("header2", "");
      connection.setRequestProperty("header3", "apple=orange");
      connection.setConnectTimeout(3000);
      connection.setReadTimeout(3000);
      StreamUtils.copy(connection.getInputStream(), new NullOutputStream());
    } catch (final Throwable t) {
      t.printStackTrace();
      Assert.fail(t.toString());
    }
  }
});

代码示例来源:origin: jberkel/sms-backup-plus

private HttpsURLConnection postTokenEndpoint(String payload) throws IOException {
  HttpsURLConnection connection = (HttpsURLConnection) new URL(TOKEN_URL).openConnection();
  connection.setDoOutput(true);
  connection.setRequestMethod("POST");
  connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
  final OutputStream os = connection.getOutputStream();
  BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
  writer.write(payload);
  writer.flush();
  writer.close();
  os.close();
  return connection;
}

代码示例来源:origin: ihaolin/antares

private static HttpsURLConnection createConnection(String url, String method, Boolean encode) {
    try {
      URL u = new URL(encode ? HttpRequest.encode(url) : url);
      HttpsURLConnection conn = (HttpsURLConnection) u.openConnection();
      conn.setRequestMethod(method);
      return conn;
    } catch (IOException e) {
      throw new HttpException(e);
    }
  }
}

代码示例来源:origin: me.hao0/common

private static HttpsURLConnection createConnection(String url, String method, Boolean encode) {
    try {
      URL u = new URL(encode ? HttpRequest.encode(url) : url);
      HttpsURLConnection conn = (HttpsURLConnection) u.openConnection();
      conn.setRequestMethod(method);
      return conn;
    } catch (IOException e) {
      throw new HttpsException(e);
    }
  }
}

代码示例来源:origin: facebook/facebook-java-business-sdk

public ResponseWrapper sendDelete(String apiUrl, Map<String, Object> allParams, APIContext context) throws APIException, IOException {
 URL url = new URL(RequestHelper.constructUrlString(apiUrl, allParams));
 context.log("Delete: " + url.toString());
 HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
 con.setRequestMethod("DELETE");
 con.setRequestProperty("User-Agent", USER_AGENT);
 return readResponse(con);
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private Map<Address, Address> callService() throws IOException, CertificateException {
  URL url = new URL(endpointUrl);
  HttpsURLConnection httpsConnection = (HttpsURLConnection) url.openConnection();
  httpsConnection.setRequestMethod("GET");
  httpsConnection.setConnectTimeout(connectionTimeoutInMillis);
  httpsConnection.setReadTimeout(connectionTimeoutInMillis);
  httpsConnection.setRequestProperty("Accept-Charset", "UTF-8");
  httpsConnection.connect();
  checkCertificate(httpsConnection);
  checkError(httpsConnection);
  return parseResponse(httpsConnection.getInputStream());
}

代码示例来源:origin: microg/AppleWifiNlpBackend

private static void prepareConnection(HttpsURLConnection connection,
    int length) throws ProtocolException {
  connection.setRequestMethod("POST");
  connection.setDoInput(true);
  connection.setDoOutput(true);
  connection.setUseCaches(false);
  connection.setRequestProperty(HTTP_FIELD_CONTENT_TYPE, CONTENT_TYPE_URLENCODED);
  connection.setRequestProperty(HTTP_FIELD_CONTENT_LENGTH, String.valueOf(length));
}

相关文章

HttpsURLConnection类方法