access HTTP payload in Java

Z

zhengyu

Hi, I am looking for ways to access HTTP payload, i.e. HTTP message stripped
of the header.
I searched thru various classes under Java.net, but could not find anything
that fits what
I have mind. I was expecting to be able to retrieve the HTTP body in a
single byte array, or something
similar. Is my expectation correct??

Cheers,
Jimmy
 
A

Andy Fish

if you are on the server and writing a servlet, just use getInputStream

if you are writing an HTTP client, try using the jakarta commons http client
package.
 
J

Jimmy Zhang

Is it possible to retrieve the byte from the input stream into a large byte
array?
Thanks,
Jimmy
 
J

Jimmy Zhang

Sorry, my real question is that if there is a way to access the underlying
buffers of the input stream object instead of
allocating then copying to another piece of memory.
Also does the input stream give access to headers or only to the
payload/body?

Thanks,
Jimmy
Also is there a way to
 
A

Andy Fish

the inputstream object gives access to the body only. there are other
methods on the request object to access the header fields

I don't think you can directly access the buffers of the underlying input
stream - you would need to read or copy it using the normal java mechanisms
for processing input streams. apart from a marginal increase in performance
I don't see why you would want to do this anyway.

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top