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

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

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

HttpsURLConnection.getHeaderFields介绍

暂无

代码示例

代码示例来源:origin: com.microsoft.azure.iothub-java-client/iothub-java-device-client

/**
 * Returns the response headers as a {@link Map}, where the key is the
 * header field name and the values are the values associated with the
 * header field name.
 *
 * @return the response headers.
 *
 * @throws IOException if no response was received.
 */
public Map<String, List<String>> getResponseHeaders() throws IOException
{
  // Codes_SRS_HTTPSCONNECTION_11_017: [The function shall return a mapping of header field names to the values associated with the header field name.]
  // Codes_SRS_HTTPSCONNECTION_11_018: [The function shall throw an IOException if no response was received.]
  return this.connection.getHeaderFields();
}

代码示例来源:origin: Azure/azure-iot-sdk-java

/**
 * Returns the response headers as a Map, where the key is the header field
 * name and the values are the values associated with the header field
 * name.
 *
 * @return the response headers.
 *
 * @throws IOException This exception thrown if no response was received.
 */
public Map<String, List<String>> getResponseHeaders() throws IOException
{
  // Codes_SRS_SERVICE_SDK_JAVA_HTTPCONNECTION_12_022: [The function shall return a mapping of header field names to the values associated with the header field name.]
  // Codes_SRS_SERVICE_SDK_JAVA_HTTPCONNECTION_12_023: [The function shall throw an IOException if no response was received.]
  return this.connection.getHeaderFields();
}

代码示例来源:origin: Azure/azure-iot-sdk-java

/**
 * Returns the response headers as a Map, where the key is the header field
 * name and the values are the values associated with the header field
 * name.
 *
 * @return the response headers.
 *
 * @throws IOException This exception thrown if no response was received.
 */
public Map<String, List<String>> getResponseHeaders() throws IOException
{
  // Codes_SRS_HTTPCONNECTION_25_022: [The function shall return a mapping of header field names to the values associated with the header field name.]
  // Codes_SRS_HTTPCONNECTION_25_023: [The function shall throw an IOException if no response was received.]
  return this.connection.getHeaderFields();
}

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

private static ResponseWrapper readResponse(HttpsURLConnection con) throws APIException, IOException {
 try {
  int responseCode = con.getResponseCode();
  String header = convertToString(con.getHeaderFields());
  BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
  String inputLine;
  StringBuilder response = new StringBuilder();
  while ((inputLine = in.readLine()) != null) {
   response.append(inputLine);
  }
  in.close();
  return new ResponseWrapper(response.toString(), header);
 } catch(Exception e) {
  BufferedReader in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
  String inputLine;
  StringBuilder response = new StringBuilder();
  while ((inputLine = in.readLine()) != null) {
   response.append(inputLine);
  }
  in.close();
  throw new APIException.FailedRequestException(response.toString(), e);
 }
}

代码示例来源:origin: spoofzu/DeepViolet

result = conn.getHeaderFields();

代码示例来源:origin: adjust/android_sdk

public static UtilsNetworking.HttpResponse sendPostI(String path, String clientSdk, String testNames, Map<String, String> postBody) {
  String targetURL = TestLibrary.baseUrl + path;
  try {
    connectionOptions.clientSdk = clientSdk;
    connectionOptions.testNames = testNames;
    HttpsURLConnection connection = createPOSTHttpsURLConnection(
        targetURL, postBody, connectionOptions);
    UtilsNetworking.HttpResponse httpResponse = readHttpResponse(connection);
    debug("Response: %s", httpResponse.response);
    httpResponse.headerFields= connection.getHeaderFields();
    debug("Headers: %s", httpResponse.headerFields);
    return httpResponse;
  } catch (IOException e) {
    error(e.getMessage());
  } catch (Exception e) {
    error(e.getMessage());
  }
  return null;
}

代码示例来源:origin: Microsoft/azure-tools-for-java

@NotNull
private static HttpResponse getResponse(@NotNull HttpsURLConnection sslConnection)
    throws IOException {
  int code = sslConnection.getResponseCode();
  String message = Strings.nullToEmpty(sslConnection.getResponseMessage());
  Map<String, List<String>> headers = sslConnection.getHeaderFields();
  if (headers == null) {
    headers = new HashMap<String, List<String>>();
  }
  InputStream is;
  String content;
  try {
    is = sslConnection.getInputStream();
  } catch (IOException e) {
    is = sslConnection.getErrorStream();
  }
  if (is != null) {
    content = readStream(is);
  } else {
    content = "";
  }
  return new HttpResponse(code, message, headers, content);
}

代码示例来源:origin: org.wso2.esb.integration/integration-base

restResponse.setHeadersMap(httpsConnection.getHeaderFields());

代码示例来源:origin: wso2-attic/esb-connectors

restResponse.setHeadersMap(httpsConnection.getHeaderFields());

代码示例来源:origin: org.wso2.esb.integration/integration-base

restResponse.setHeadersMap(httpsConnection.getHeaderFields());

代码示例来源:origin: wso2-attic/esb-connectors

restResponse.setHeadersMap(httpsConnection.getHeaderFields());

代码示例来源:origin: org.wso2.esb.integration/integration-base

/**
 * Send HTTPS request using {@link HttpsURLConnection} in XML format.
 *
 * @param endPoint String End point URL.
 * @param httpMethod String HTTPS method type (POST, PUT)
 * @param headersMap Map<String, String> Headers need to send to the end point.
 * @param fileName File name of the attachment to set as binary content.
 * @return RestResponse object.
 * @throws IOException
 * @throws XMLStreamException
 */
protected RestResponse<OMElement> sendBinaryContentForXmlResponseHTTPS(String endPoint, String httpMethod,
                                    Map<String, String> headersMap, String fileName)
    throws IOException, XMLStreamException {
  HttpsURLConnection httpsConnection =
      writeRequestHTTPS(endPoint, httpMethod, RestResponse.XML_TYPE, headersMap, fileName, true);
  String responseString = readResponse(httpsConnection);
  RestResponse<OMElement> restResponse = new RestResponse<OMElement>();
  restResponse.setHttpStatusCode(httpsConnection.getResponseCode());
  restResponse.setHeadersMap(httpsConnection.getHeaderFields());
  if (responseString != null) {
    restResponse.setBody(AXIOMUtil.stringToOM(responseString));
  }
  return restResponse;
}

代码示例来源:origin: wso2-attic/esb-connectors

restResponse.setHeadersMap(httpsConnection.getHeaderFields());

代码示例来源:origin: wso2-attic/esb-connectors

restResponse.setHeadersMap(httpsConnection.getHeaderFields());

代码示例来源:origin: org.wso2.esb.integration/integration-base

restResponse.setHeadersMap(httpsConnection.getHeaderFields());

相关文章

HttpsURLConnection类方法