我正在HttpURLConnection類從我的應用程序做一些網絡活動。所以我想知道HttpURLConnection如何在內部工作。我經歷了課程,發現連接()方法定義爲URLConnection中的摘要。Android HttpURLConnection如何工作?
但我無法找到連接()方法的定義。所以我很好奇,HttpURLConnection如何連接到服務器。
mycode的:
URL url = new URL("https://example.com");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Accept-Encoding", "identity");
connection.setRequestProperty("Authorization", basicAuth);
connection.setRequestProperty("Connection", "keep-alive");
connection.setRequestProperty("Content-type", "");
connection.setRequestProperty("User-Agent", "LibHttp/1.3.8");
connection.setRequestMethod("POST");
connection.connect(); // how it connects //
請建議我一些解決方案。
也許這可能會幫助你[Java URLConnection - 我什麼時候需要使用connect()方法?](http://stackoverflow.com/questions/16122999/java-urlconnection-when-do-i-need-使用該連接方法) – Isabelle