1.å¦ä½ä½¿ç¨HttpClient
å¦ä½ä½¿ç¨HttpClient
ä¸ãç®ä»
HttpClientæ¯Apache Jakarta Commonä¸çå项ç®ï¼ç¨æ¥æä¾é«æçãææ°çãåè½ä¸°å¯çæ¯æHTTPåè®®ç客æ·ç«¯ç¼ç¨å·¥å ·å ï¼å¹¶ä¸å®æ¯æHTTPåè®®ææ°ççæ¬å建议ãHttpClientå·²ç»åºç¨å¨å¾å¤ç项ç®ä¸ï¼æ¯å¦Apache Jakartaä¸å¾èåçå¦å¤ä¸¤ä¸ªå¼æºé¡¹ç®CactusåHTMLUnité½ä½¿ç¨äºHttpClientã
äºãç¹æ§
1. åºäºæ åã纯åçjavaè¯è¨ãå®ç°äºHttp1.0åHttp1.1
2. 以å¯æ©å±çé¢å对象çç»æå®ç°äºHttpå ¨é¨çæ¹æ³ï¼GET,abp zero 6.7 源码 POST, PUT, DELETE, HEAD, OPTIONS, and TRACEï¼ã
3. æ¯æHTTPSåè®®ã
4. éè¿Http代ç建ç«éæçè¿æ¥ã
5. å©ç¨CONNECTæ¹æ³éè¿Http代ç建ç«é§éç.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.List;
import javax.net.ssl.SSLContext;
import org.apache.ment = new StringBody("A binary file of some kind", ContentType.TEXT_PLAIN);
HttpEntity reqEntity = MultipartEntityBuilder.create().addPart("bin", bin).addPart("comment", comment).build();
httppost.setEntity(reqEntity);
System.out.println("executing request " + httppost.getRequestLine());
CloseableHttpResponse response = httpclient.execute(httppost);
try {
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
System.out.println("Response content length: " + resEntity.getContentLength());
}
EntityUtils.consume(resEntity);
} finally {
response.close();
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
httpclient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}</namevaluepair></namevaluepair></namevaluepair></namevaluepair>
2024-11-19 09:05118人浏览
2024-11-19 09:012256人浏览
2024-11-19 08:301088人浏览
2024-11-19 08:29676人浏览
2024-11-19 07:561232人浏览
2024-11-19 06:58469人浏览
輝達執行長黃仁勳日前來台參加COMPUTEX,結束為期兩週的固樁行程之後,市場傳出由於AI需求增加,蘋果、高通、輝達與超微等四大廠,大舉包下台積電3奈米家族製程產能,並湧現客戶排隊潮,一路排到2026
拜登上午八點將發表紓困演說,美股先慶祝後保守。但,台積電ADR先暴衝了。您的閱讀篇數已達上限立刻訂閱全閱讀,即可享全站不限篇數閱讀