HttpURLConnection implementation

前端 未结 6 1106
自闭症患者
自闭症患者 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条回答
  •  伪装坚强ぢ
    2020-12-09 10:39

    Hmmh. I may be missing something here (since this is an old question), but as far as I know, there are 2 well-known ways to force closing of the underlying TCP connection:

    • Force use of HTTP 1.0 (1.1 introduced persistent connections) -- this as indicated by the http request line
    • Send 'Connection' header with value 'close'; this will force closing as well.

提交回复
热议问题