I think the thread at 
http://www.mail-archive.com/[email protected]/msg02313.html
discusses this in some depth.

-----Original Message-----
From: Kevin Jones
To: Jakarta Commons Developers List
Sent: 2/19/02 1:32 AM
Subject: HttpClient

Folks,

Not sure if this is the best place to ask but there's no user list and I
couldn't find any samples (I've even grepped the Slide code!). I'm
trying to use HttpClient to POST data to a servlet but I can't get the
code to automatically set the content length (the java.net.*URL* classes
do this) and wondered if I was missing something. I have this

HttpConnection con = new HttpConnection(url.getHost(), port);
PostMethod httpMethod = new PostMethod(url.getPath());
        
httpMethod.setRequestHeader("contentType", "text/xml");

httpMethod.execute(new HttpState(), con);
con.open();
sendData(con.getRequestOutputStream());

I can't call getRequestOutputStream before() I call open().
If I send the data before I execute() then the data is streamed out of
the socket on the send, then the execute() cause the request line and
HTTP headers to be sent (i.e. things go in the wrong order). Is there an
easy way to achieve what I want or do I have to calculate the size of
the data myself before I send it?

Thanks,

Kevin Jones
Developmentor
www.develop.com 


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

Reply via email to