1

In java.net.URLConnetion.java and java.net.HttpURLConnection.java, there are only abstract methods for connect() and disconnect(), respectively.

@ abstract public void connect() throws IOException;
@ public abstract void disconnect();

Does anyone know where is the actual codes that implement them?

I want to know how the HttpURLConnection communicate with TCP stack.

Besides, there are more abstract functions, such as usingProxy(). Where is the code for them?

Damian Kozlak
  • 7,065
  • 10
  • 45
  • 51

1 Answers1

0

java.net.HttpURLConnection.java has an implementation HttpsURLConnectionImpl that has implemented the method. It uses a delegate DelegateHttpsURLConnection that extends AbstractDelegateHttpsURLConnection which has implemented the connect() method

Most IDE's you can track all the classes, objects and methods, and download the source files. Fx. IntelliJ can do this for you.

Martin Hansen
  • 2,033
  • 1
  • 18
  • 34
  • Oh, thanks for your answer! Is it done automatically? I just need to call HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.connect() to connect to a server. How come there is no explicit calling of HttpsURLConnectionImpl DelegateHttpsURLConnection AbstractDelegateHttpsURLConnection ? @ by the way, why all of the classes you wrote contain http's'? – Sooyoung Jang Dec 08 '15 at 11:41
  • I think i have a plugin to automatically decompile source files (Java Bytecode Decompiler) that automatically decompiles source files. `IntelliJ` will normally ask you to download the original source file if its available. – Martin Hansen Dec 08 '15 at 11:44
  • I just took a random implementation of `HttpURLConnection` there is multiple of these around. – Martin Hansen Dec 08 '15 at 11:46
  • Do you know, which implementation of HttpURLConnection is used for Android? – Sooyoung Jang Dec 08 '15 at 11:59
  • Sadly i don't. i found this link though: http://developer.android.com/reference/java/net/HttpURLConnection.html, maybe this could help further investigation – Martin Hansen Dec 08 '15 at 12:26
  • Thanks, Martin. I've looked through that but I couldn't find my answer. :( – Sooyoung Jang Dec 08 '15 at 23:10