有没有办法从Java servlet处理程序获取原始http请求流? [英] Is there a way to get raw http request stream from Java servlet handler?

查看:243
本文介绍了有没有办法从Java servlet处理程序获取原始http请求流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些日志记录捕获到我的应用程序的原始http请求。我的Java代码在SpringMVC控制器中。我可以访问HttpServletRequest对象。但我找不到一种方法来获取原始的http请求流。有一个读者,但只阅读帖子内容。我想要的是整个shebang,url,标题,身体。是否有捷径可寻?

I am trying to put some logging to capture the raw http request coming to my application. My Java code is inside a SpringMVC controller. I have access to the "HttpServletRequest" object. But I could not find a way to get the raw http request stream out of it. There is a reader but only reads the post content. What I want is the whole shebang, the url, the headers, the body. Is there an easy way to do this?

提前致谢。

推荐答案

不,servlet没有提供api来获取原始请求 - 你可能需要一个类似wireshark的嗅探器。

No, servlets provide no api to get at the raw request - you might need a sniffer like wireshark for that.

你可以得到解析后的请求标题和uri:

You can get at the parsed request headers and uri though:

  • getHeaderNames()
  • getRequestURI()

等。

这篇关于有没有办法从Java servlet处理程序获取原始http请求流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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