如何从没有响应头的服务器显式终止http连接 [英] How to explicitly terminate http connection from server with no response header

查看:137
本文介绍了如何从没有响应头的服务器显式终止http连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的一个客户端应用程序开发服务器模拟器。我正在使用GlassFish服务器。我必须在我的服务器应用程序中模拟http连接终止条件。

I am developing a server simulator for one of my client application. I am using GlassFish server. I have to simulate a http connection terminate condition in my server application.

有没有办法可以显式终止服务器端的连接,这样客户端就不会收到任何响应头。目前我已经尝试了许多选项,比如关闭响应outputStream。但是在每种情况下都会将http 200 OK消息传递给客户端应用程序。我想使用http请求并且不想向客户端返回任何内容。

Is there a way by which I can explicitly terminate a connection from server side such that client does not receive any response header. Currently I have tried many options like closing the response outputStream. But in every case a http 200 OK message is delivered to the client application. I would like to consume the http-request and do not want to return anything to the client.

我使用的是一个简单的conrtroller servlet并且已经覆盖了 doGet() doPost()函数。

I am using a simple conrtroller servlet and had overridden doGet() and doPost() functions.

推荐答案

你很难说服appserver执行此操作,它们的设计非常强大。

You're going to have difficulty persuading an appserver to do this, they're designed to be robust.

我建议看看 Jetty ,这是一个可嵌入且高度可配置的HTTP / servlet框架,您可以将其用作appserver构建的替代方案 - 支持。您很有可能使用自定义连接处理程序对其进行配置,并希望执行特定的连接终止。

I suggest taking a look at Jetty, which is an embeddable and highly configurable HTTP/servlet framework which you can use as alternative to the appserver's built-in support. There's a good chance you'll be able to configure it with a customized connection handler, and hopefully perform your specific connection terminations.

这篇关于如何从没有响应头的服务器显式终止http连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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