Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Dumping the headers

Hi,

On Wed, Dec 20, 2017 at 9:39 AM, Martin Grajcar <maaartinus@xxxxxxxxx> wrote:
> Actually, my application always needs the full content. I'd gladly trade the
> stream for a byte[] anytime. I guess, there's no out of the box solution for
> this and I need to use request.startAsync, right?

You don't *need* to call startAsync().
You just read from the ServletInputStream.

> Slightly related: Can I get the headers as text just like they were sent?

No.

> I want to do a full dump of some requests and dumping exactly what arrived
> would be best.

What arrives are bytes, not text.
The bytes that represent the HTTP headers can be fragmented by the
sender or by TCP.
The bytes may contain both HTTP headers and content.
We would need to parse the bytes to understand where the headers finish.

Have a look at https://github.com/eclipse/jetty.project/blob/jetty-9.4.8.v20171121/jetty-server/src/test/java/org/eclipse/jetty/server/NetworkTrafficListenerTest.java
if you want to intercept the bytes that arrive at the connector; but
then you're on your own and you need to parse them.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.


Back to the top