91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3.09MB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2023-11-06
  • 語言: Java
  • 標簽: httpclient??

資源簡介

HttpClient配置SSL繞過https證書實例,附件中包含所需httpclient組件jar庫。博客地址:http://blog.csdn.net/irokay/article/details/78801307。

資源截圖

代碼片段和文件信息

/*
?*?====================================================================
?*?Licensed?to?the?Apache?Software?Foundation?(ASF)?under?one
?*?or?more?contributor?license?agreements.??See?the?NOTICE?file
?*?distributed?with?this?work?for?additional?information
?*?regarding?copyright?ownership.??The?ASF?licenses?this?file
?*?to?you?under?the?Apache?License?Version?2.0?(the
?*?“License“);?you?may?not?use?this?file?except?in?compliance
?*?with?the?License.??You?may?obtain?a?copy?of?the?License?at
?*
?*???http://www.apache.org/licenses/LICENSE-2.0
?*
?*?Unless?required?by?applicable?law?or?agreed?to?in?writing
?*?software?distributed?under?the?License?is?distributed?on?an
?*?“AS?IS“?BASIS?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY
?*?KIND?either?express?or?implied.??See?the?License?for?the
?*?specific?language?governing?permissions?and?limitations
?*?under?the?License.
?*?====================================================================
?*
?*?This?software?consists?of?voluntary?contributions?made?by?many
?*?individuals?on?behalf?of?the?Apache?Software?Foundation.??For?more
?*?information?on?the?Apache?Software?Foundation?please?see
?*?.
?*
?*/

package?test;

import?java.io.IOException;

import?org.apache.http.HttpEntity;
import?org.apache.http.HttpResponse;
import?org.apache.http.client.ClientProtocolException;
import?org.apache.http.client.ResponseHandler;
import?org.apache.http.client.methods.HttpGet;
import?org.apache.http.impl.client.CloseableHttpClient;
import?org.apache.http.impl.client.HttpClients;
import?org.apache.http.util.EntityUtils;

/**
?*?This?example?demonstrates?the?use?of?the?{@link?ResponseHandler}?to?simplify
?*?the?process?of?processing?the?HTTP?response?and?releasing?associated?resources.
?*/
public?class?ClientWithResponseHandler?{

????public?final?static?void?main(String[]?args)?throws?Exception?{
????????CloseableHttpClient?httpclient?=?HttpClients.createDefault();
????????try?{
????????????HttpGet?httpget?=?new?HttpGet(“https://www.baidu.com/“);

????????????System.out.println(“Executing?request?“?+?httpget.getRequestLine());

????????????//?Create?a?custom?response?handler
????????????ResponseHandler?responseHandler?=?new?ResponseHandler()?{

????????????????@Override
????????????????public?String?handleResponse(
????????????????????????final?HttpResponse?response)?throws?ClientProtocolException?IOException?{
????????????????????int?status?=?response.getStatusLine().getStatusCode();
????????????????????if?(status?>=?200?&&?status?????????????????????????HttpEntity?entity?=?response.getEntity();
????????????????????????return?entity?!=?null???EntityUtils.toString(entity)?:?null;
????????????????????}?else?{
????????????????????????throw?new?ClientProtocolException(“Unexpected?response?status:?“?+?status);
????????????????????}
????????????????}

????????????};
????????????String?responseBody?=?httpclient

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-13?13:32??HttpUtil\
?????文件????????1296??2017-12-13?14:39??HttpUtil\.classpath
?????文件?????????384??2017-12-13?13:32??HttpUtil\.project
?????目錄???????????0??2017-12-13?13:32??HttpUtil\.settings\
?????文件?????????598??2017-12-13?13:32??HttpUtil\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2017-12-13?14:59??HttpUtil\bin\
?????目錄???????????0??2017-12-14?11:43??HttpUtil\bin\test\
?????文件????????1764??2017-12-14?11:59??HttpUtil\bin\test\ClientWithResponseHandler$1.class
?????文件????????1959??2017-12-14?11:59??HttpUtil\bin\test\ClientWithResponseHandler.class
?????文件????????1020??2017-12-14?12:11??HttpUtil\bin\test\HttpsGetUtil$1.class
?????文件????????4300??2017-12-14?12:11??HttpUtil\bin\test\HttpsGetUtil.class
?????文件????????1024??2017-12-14?11:45??HttpUtil\bin\test\HttpsPostUtil$1.class
?????文件????????4327??2017-12-14?11:45??HttpUtil\bin\test\HttpsPostUtil.class
?????目錄???????????0??2017-12-13?14:59??HttpUtil\src\
?????目錄???????????0??2017-12-14?11:43??HttpUtil\src\test\
?????文件????????3238??2017-12-14?11:59??HttpUtil\src\test\ClientWithResponseHandler.java
?????文件????????4049??2017-12-14?12:11??HttpUtil\src\test\HttpsGetUtil.java
?????文件????????5162??2017-12-14?11:45??HttpUtil\src\test\HttpsPostUtil.java
?????文件?????3240923??2017-12-13?14:38??httpcomponents-client-4.5.4-bin.zip

評論

共有 條評論