exclude http headers from reponse?

Hi all,

I post data to a server and get response[in xml] back like this

Socket theSock =new Socket(serverhost,80);

PrintStream ps =new PrintStream(theSock.getOutputStream());

ps.println("POST /url HTTP/1.0");

.

.

SAXBuilder builder =new SAXBuilder();//==<< get reponse

Document doc = builder.build(theSock.getInputStream());

.

.

at builder.build I've got "SAXException: Parsing Error : The root element is required in a well-formed document" .

that because output from theSock.getInputStream() is

HTTP/1.1 200 OK

Date: Wed, 04 Jul 2007 10:14:54 GMT

Content-Length: 105

Content-Type: text/xml;charset=UTF-8

.

.

Connection: close

<resp>

<status>200</status>

<description>ok</description>

</resp>

I know that if i use HttpURLConnection the response InputStream will not contain http headers. But I'm just curious that with Socket, Is there any trick to get only content from InputStream?

[1240 byte] By [worapoj@gmail.coma] at [2007-11-27 9:43:53]
# 1

There is no trick except to use the HttpUrlConnection class. That抯 why it was created. It wraps the socket and parses through the headers for you. The socket is very low level and all it sees are bits over an input stream (TCP / UDP). It does not know or care about HTTP which is a protocol on top of TCP.

Super_Squirrela at 2007-7-12 23:49:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
thanks, Super_Squirrel.
worapoj@gmail.coma at 2007-7-12 23:49:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...