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

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

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

HttpsURLConnection.getHeaderField介绍

暂无

代码示例

代码示例来源:origin: KickVN/SaliensAuto

private int getEResult(HttpsURLConnection conn) {
  String s = conn.getHeaderField("x-eresult");
  if(s==null) s = conn.getHeaderField("X-eresult");
  if(s==null) return -1;
  return Integer.valueOf(s);
}

代码示例来源:origin: KickVN/SaliensAuto

private String getErrorMessage(HttpsURLConnection conn) {
  String s = conn.getHeaderField("x-error_message");
  if(s==null) s = conn.getHeaderField("X-error_message");
  return convertErrorMessage(eResult,s);
}

代码示例来源:origin: AzureAD/azure-activedirectory-library-for-java

static void verifyReturnedCorrelationId(Logger log,
    HttpsURLConnection conn, String sentCorrelationId) {
  if (StringHelper
      .isBlank(conn
          .getHeaderField(ClientDataHttpHeaders.CORRELATION_ID_HEADER_NAME))
      || !conn.getHeaderField(
      ClientDataHttpHeaders.CORRELATION_ID_HEADER_NAME)
      .equals(sentCorrelationId)) {
    String msg = LogHelper.createMessage(
        String.format(
            "Sent (%s) Correlation Id is not same as received (%s).",
            sentCorrelationId,
            conn.getHeaderField(ClientDataHttpHeaders.CORRELATION_ID_HEADER_NAME)),
        sentCorrelationId);
    log.info(msg);
  }
}

代码示例来源:origin: com.microsoft.azure/adal4j

static void verifyReturnedCorrelationId(Logger log,
    HttpsURLConnection conn, String sentCorrelationId) {
  if (StringHelper
      .isBlank(conn
          .getHeaderField(ClientDataHttpHeaders.CORRELATION_ID_HEADER_NAME))
      || !conn.getHeaderField(
      ClientDataHttpHeaders.CORRELATION_ID_HEADER_NAME)
      .equals(sentCorrelationId)) {
    String msg = LogHelper.createMessage(
        String.format(
            "Sent (%s) Correlation Id is not same as received (%s).",
            sentCorrelationId,
            conn.getHeaderField(ClientDataHttpHeaders.CORRELATION_ID_HEADER_NAME)),
        sentCorrelationId);
    log.info(msg);
  }
}

代码示例来源:origin: MissionCriticalCloud/cosmic

httpsConn = (HttpsURLConnection) uri.toURL().openConnection();
if (httpsConn != null) {
  final String contentLength = httpsConn.getHeaderField("content-length");
  if (contentLength != null) {
    remoteSize = Long.parseLong(contentLength);

代码示例来源:origin: youngMen1/JAVA-

conn.setDoInput(true);
String disposition = conn.getHeaderField("Content-disposition");
if (disposition == null) {
  return null;

代码示例来源:origin: ansitech/weixin4j

String ds = https.getHeaderField("Content-disposition");
String fullName = ds.substring(ds.indexOf("filename=\"") + 10, ds.length() - 1);
String relName = fullName.substring(0, fullName.lastIndexOf("."));
attachment.setFileName(relName);
attachment.setSuffix(suffix);
attachment.setContentLength(https.getHeaderField("Content-Length"));
attachment.setContentType(https.getHeaderField("Content-Type"));

代码示例来源:origin: ch.cern.hadoop/hadoop-common

@Test
public void testHttpsCookie() throws IOException, GeneralSecurityException {
 URL base = new URL("https://" + NetUtils.getHostPortString(server
     .getConnectorAddress(1)));
 HttpsURLConnection conn = (HttpsURLConnection) new URL(base,
     "/echo").openConnection();
 conn.setSSLSocketFactory(clientSslFactory.createSSLSocketFactory());
 String header = conn.getHeaderField("Set-Cookie");
 List<HttpCookie> cookies = HttpCookie.parse(header);
 Assert.assertTrue(!cookies.isEmpty());
 Assert.assertTrue(header.contains("; HttpOnly"));
 Assert.assertTrue(cookies.get(0).getSecure());
 Assert.assertTrue("token".equals(cookies.get(0).getValue()));
}

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

JSONObject js = new JSONObject(new JSONTokener(con.getInputStream()));
if (js.has("connect")) {
  cookie = con.getHeaderField("Set-Cookie");
  return;

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

@Test
public void testHttpsCookie() throws IOException, GeneralSecurityException {
 URL base = new URL("https://" + NetUtils.getHostPortString(server
     .getConnectorAddress(1)));
 HttpsURLConnection conn = (HttpsURLConnection) new URL(base,
     "/echo").openConnection();
 conn.setSSLSocketFactory(clientSslFactory.createSSLSocketFactory());
 String header = conn.getHeaderField("Set-Cookie");
 List<HttpCookie> cookies = HttpCookie.parse(header);
 Assert.assertTrue(!cookies.isEmpty());
 Assert.assertTrue(header.contains("; HttpOnly"));
 Assert.assertTrue(cookies.get(0).getSecure());
 Assert.assertTrue("token".equals(cookies.get(0).getValue()));
}

代码示例来源:origin: com.dslplatform/dsl-clc

tag = "1.3.1";
} else {
  final String redirect = conn.getHeaderField("Location");
  tag = redirect.substring(redirect.lastIndexOf('/') + 1);

代码示例来源:origin: org.apache.taverna.engine/taverna-credential-manager-impl

System.out.println("Status header: "+ conn2.getHeaderField(0));
assertEquals("HTTP/1.1 200 OK", conn2.getHeaderField(0));
conn2.disconnect();

代码示例来源:origin: Microsoft/AppCenter-SDK-Android

ByteArrayInputStream inputStream = spy(new ByteArrayInputStream(payload.getBytes()));
when(urlConnection.getInputStream()).thenReturn(inputStream);
when(urlConnection.getHeaderField("Content-Type")).thenReturn(mimeType);

代码示例来源:origin: net.sf.taverna.t2.security/credential-manager-impl

System.out.println("Status header: "+ conn2.getHeaderField(0));
assertEquals("HTTP/1.1 200 OK", conn2.getHeaderField(0));
conn2.disconnect();

代码示例来源:origin: Microsoft/AppCenter-SDK-Android

ByteArrayInputStream inputStream = spy(new ByteArrayInputStream("fake binary".getBytes()));
when(urlConnection.getInputStream()).thenReturn(inputStream);
when(urlConnection.getHeaderField("Content-Type")).thenReturn("image/png");

代码示例来源:origin: apache/jackrabbit-oak

assertEquals(200, conn.getResponseCode());
assertEquals(mimeType, conn.getHeaderField("Content-Type"));
assertEquals(
    String.format("%s; filename=\"%s\"; filename*=UTF-8''%s",
        new String(fileName.getBytes(StandardCharsets.UTF_8))
    ),
    conn.getHeaderField("Content-Disposition")
);

代码示例来源:origin: org.apache.taverna.engine/taverna-credential-manager-impl

assertEquals("HTTP/1.1 200 OK", conn2.getHeaderField(0));
conn2.disconnect();

代码示例来源:origin: net.sf.taverna.t2.security/credential-manager-impl

assertEquals("HTTP/1.1 200 OK", conn2.getHeaderField(0));
conn2.disconnect();

代码示例来源:origin: org.apache.taverna.engine/taverna-credential-manager-impl

assertEquals("HTTP/1.1 200 OK", conn.getHeaderField(0));
conn.disconnect();
assertEquals("HTTP/1.1 200 OK", conn.getHeaderField(0));
conn.disconnect();

代码示例来源:origin: net.sf.taverna.t2.security/credential-manager-impl

assertEquals("HTTP/1.1 200 OK", conn.getHeaderField(0));
conn.disconnect();
assertEquals("HTTP/1.1 200 OK", conn.getHeaderField(0));
conn.disconnect();

相关文章

HttpsURLConnection类方法