Use of java.net.URLConnection
is asked about pretty often here, and the Oracle tutorial is too concise about it.
(在这里经常会问到使用java.net.URLConnection
情况,而Oracle教程对此过于简洁。)
That tutorial basically only shows how to fire a GET request and read the response.
(该教程基本上仅显示如何触发GET请求并读取响应。)
It doesn't explain anywhere how to use it to among others perform a POST request, set request headers, read response headers, deal with cookies, submit a HTML form, upload a file, etc. (它没有任何地方说明如何使用它来执行POST请求,设置请求标头,读取响应标头,处理cookie,提交HTML表单,上传文件等。)
So, how can I use java.net.URLConnection
to fire and handle "advanced" HTTP requests?
(因此,如何使用java.net.URLConnection
来触发和处理“高级” HTTP请求?)
ask by community wiki translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…