首页 > dalvik的luni中HttpURLConnection.java为什么没有overridde getInputSteam方法

dalvik的luni中HttpURLConnection.java为什么没有overridde getInputSteam方法

想看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类,当然有子类才能使用啦!

class HttpURLConnectionImpl extends HttpURLConnection

见:
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

【热门文章】
【热门文章】