目錄
Java 9中的Http/2客戶端是什麼?
Http/2 Client API在 Java 9 中引入。它比 Http/1.1 具有更多效能改進,並且還支援伺服器端推送事件。這使得網站高效且更快瀏覽。 Http/2 Client是一個名為jdk.incubator.httpclient的孵化器模組strong>,這意味著所有功能還沒有最終確定,新的變化可能會在java 的未來版本中出現。它會匯出包含所有公共 API 的 jdk.incubator.http 套件。
要使用 Http/2 客戶端,我們需要使用孵化器模組,我們只需使用“–add-modules”命令將httpclient 模組傳遞到JShell 中,如下所示
<strong>C:\>jshell -v --add-modules jdk.incubator.httpclient | Welcome to JShell -- Version 9.0.4 | For an introduction type: /help intro</strong>
登入後複製
範例
<strong>jshell> import jdk.incubator.http.*; jshell> HttpClient httpClient = HttpClient.newHttpClient(); httpClient ==> jdk.incubator.http.HttpClientImpl@534df152 | created variable httpClient : HttpClient jshell> HttpRequest httpRequest = HttpRequest.newBuilder().uri(new URI("https: //www.google.com")).GET().build(); httpRequest ==> https://www.google.com GET | created variable httpRequest : HttpRequest jshell> HttpResponse httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandler.asString()); httpResponse ==> jdk.incubator.http.HttpResponseImpl@609cd4d8 | created variable httpResponse : HttpResponse jshell> System.out.println(httpResponse.statusCode()); 403</strong> <strong> jshell> System.out.println(httpResponse.body()); Apache HTTP Server Test Page powered by CentOS Testing 123.. <p class="lead">This page is used to test the proper operation of the Apache HTTP server after it has been insta lled. If you can read this page it means that this site is working properly. Thi s server is powered by CentOS.</p><p class="lead">The website you just visited is either experiencing problems or is undergoing routine maintenance.</p>If you would like to let the administrators of this website know that you've seen this page instead of the page you expected, you should send them e-mail. In general, mail sent to the name "webmast er" and directed to the website's domain should reach the appropriate person.For example, if you experienced problems while visiting www.example.com, you should send e-mail to "webmaster@example .com". Are you the Administrator? <p>You should add your website content to the directory /var/www/html/.</p><p>To prevent this page from ever being used, follow the instructions in the file /etc/httpd/conf.d/welcome.conf.</p>Promoting Apache and CentOS </strong><p><strong>You are free to use the images below on Apache and CentOS Linux powered HTTP servers. Thanks for using Apache and CentOS!</strong></p>
登入後複製
以上是Java 9中的Http/2客戶端是什麼?的詳細內容。更多資訊請關注PHP中文網其他相關文章!
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章
R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
2 週前
By 尊渡假赌尊渡假赌尊渡假赌
倉庫:如何復興隊友
4 週前
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island冒險:如何獲得巨型種子
3 週前
By 尊渡假赌尊渡假赌尊渡假赌
擊敗分裂小說需要多長時間?
3 週前
By DDD
R.E.P.O.保存文件位置:在哪里以及如何保護它?
3 週前
By DDD

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

2025年的前4個JavaScript框架:React,Angular,Vue,Svelte

如何使用咖啡因或Guava Cache等庫在Java應用程序中實現多層緩存?

Spring Boot Snakeyaml 2.0 CVE-2022-1471問題已修復

如何將JPA(Java持久性API)用於具有高級功能(例如緩存和懶惰加載)的對象相關映射?

如何將Maven或Gradle用於高級Java項目管理,構建自動化和依賴性解決方案?
