0

HttpURLConnection が接続の入力ストリームを取得する方法に興味があります。親抽象クラス URLConnection の実装を確認したところ、メソッドが見つかりました

 /**
     * 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");
    }
  1. URLConnection を拡張する HttpURLConnection は、このメソッドをオーバーライドしません。入力ストリーム参照がどのように取得されるのか疑問に思っていましたか?

  2. これに関連する何か.... HTTPリクエストがクライアントからサーバーに送信されるのはいつですか?getInputStream() を呼び出すときですか?または openConnection() が呼び出されるとすぐに?

よろしくお願いします。

4

1 に答える 1