Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

java - 如何使用java.net.URLConnection触发和处理HTTP请求(How to use java.net.URLConnection to fire and handle HTTP requests)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...