如何使用java.net.URLConnection觸發和處理HTTP請求

問題:

Use of java.net.URLConnection is asked about pretty often here, and the Oracle tutorial is too concise about it. 在這裏常常會問到使用java.net.URLConnection狀況,而Oracle教程對此過於簡潔。 html

That tutorial basically only shows how to fire a GET request and read the response. 該教程基本上僅顯示如何觸發GET請求並讀取響應。 It doesn't explain anywhere how to use it to among others perform a POST request, set request headers, read response headers, deal with cookies, submit a HTML form, upload a file, etc. 它沒有任何地方說明如何使用它來執行POST請求,設置請求標頭,讀取響應標頭,處理cookie,提交HTML表單,上傳文件等。 java

So, how can I use java.net.URLConnection to fire and handle "advanced" HTTP requests? 所以,如何使用java.net.URLConnection來觸發和處理「高級」 HTTP請求? api


解決方案:

參考一: https://stackoom.com/question/Bico/如何使用java-net-URLConnection觸發和處理HTTP請求
參考二: https://oldbug.net/q/Bico/How-to-use-java-net-URLConnection-to-fire-and-handle-HTTP-requests
相關文章
相關標籤/搜索