HttpURLConnection implementation

前端 未结 6 1122
自闭症患者
自闭症患者 2020-12-09 10:22

I have read that HttpURLConnection supports persistent connections, so that a connection can be reused for multiple requests. I tried it and the only way to send a second PO

6条回答
  •  猫巷女王i
    2020-12-09 10:30

    From the javadoc for HttpURLConnection (my emphasis):

    Each HttpURLConnection instance is used to make a single request but the underlying network connection to the HTTP server may be transparently shared by other instances. Calling the close() methods on the InputStream or OutputStream of an HttpURLConnection after a request may free network resources associated with this instance but has no effect on any shared persistent connection. Calling the disconnect() method may close the underlying socket if a persistent connection is otherwise idle at that time.

提交回复
热议问题