想看urlconnectionde getInputStream什么时候connect的,却发现HttpUrlConnection并没有复写getInputStream这个方法啊
~ANDROID_HOME/sources/android-19/java/net/URLConnection#getInputStream
/**
* Returns an {@code InputStream} for reading data from the resource pointed by
* this {@code URLConnection}. It throws an UnknownServiceException by
* default. This method must be overridden by its subclasses.
*
* @return the InputStream to read data from.
* @throws IOException
* if no InputStream could be created.
*/
public InputStream getInputStream() throws IOException {
throw new UnknownServiceException("Does not support writing to the input stream");
}
https://android.googlesource.com/platform/libcore/+/android-4.4.2_r2/luni/src/main/java/java/net/HttpURLConnection.java
HttpURLConnection为abstract类,当然有子类才能使用啦!
见:
https://android.googlesource.com/platform/libcore/+/android-cts-4.1_r2/luni/src/main/java/libcore/net/http/HttpURLConnectionImpl.java
使用openConnection().getClass().getName()得到classname是
com.android.okhttp.internal.http.HttpURLConnectionImpl
.对应
external/okhttp/android/main/java/com/squareup/okhttp
这里用到了
java.protocol.handler.pkgs
https://android-review.googlesource.com/#/c/54970/2/luni/src/main/java/java/net/URL.java