android - dalvik的luni中HttpURLConnection.java为什么没有overridde getInputSteam方法
怪我咯
怪我咯 2017-04-17 11:33:53
0
2
479

想看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

怪我咯
怪我咯

走同样的路,发现不同的人生

모든 응답(2)
阿神

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

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿