发送GET& Java或其他无响应的POST请求 [英] Sending GET & POST requests in Java or other without responses

查看:330
本文介绍了发送GET& Java或其他无响应的POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以进行GET&用Java或其他语言发布的POST请求,这样您就不必关心返回的内容了吗?

Is it possible to make GET & POST requests in Java or another language such that you don't care about what is returned?

就像只是发送请求但不希望收到任何答复一样?

As in just sending the requests but not wanting to receive any responses?

推荐答案

无论您是否关心响应,都将发送该响应. HTTP协议规范规定必须如此.

Whether you care about the response or not, it will be sent. The HTTP protocol specifications say that it must be.

如果您不关心响应,则客户端可以在发送请求后立即关闭连接.但是即使您不想查看响应消息的内容,您也有可能想知道请求已被处理(即响应状态).
因此,也许您可​​以发送请求和请求正文,并读取响应状态,然后在不读取响应正文的情况下关闭连接.但是,这有一个缺点.这意味着您不能重用HTTP连接来发出更多请求.对同一服务器的下一个请求必须打开一个新连接.

If you don't care about the response, your client could just close the connection immediately after sending the request. But the chances are that you do want to know that the request was processed (i.e. the response status) even if you don't want to look at the contents of the response message.
So maybe you could send the request and request body, and read the response status and then close the connection without reading the response body. However, this has a downside. It means that you can't reuse the HTTP connection to make further requests. The next request to the same server has to open a new connection.

这篇关于发送GET& Java或其他无响应的POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆