You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Kevin Jones <ke...@develop.com> on 2002/02/19 08:32:54 UTC

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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>