Mark Wolter wrote:
Hi Oleg,
thanks for the hint!
I added the interface to my project, changed the code:
post.setRequestEntity(new FileRequestEntity(file, "UTF-8"));
and it worked!
is there a possibility to download the whole package "
org.apache.commons.httpclient.contrib.benchmark" ?
Mark
Hi Mark (apologies for calling you Mike in my previous mail)
The code in the 'contrib' package is provided as a reference material
only and is not distributed in a binary form. Just make a copy of this
class and tweak it any way you see fit.
Oleg
--- Ursprüngliche Nachricht ---
Von: Oleg Kalnichevski <[EMAIL PROTECTED]>
An: HttpClient User Discussion <[email protected]>
Betreff: Re: Buffered post example needed
Datum: Wed, 19 Apr 2006 21:17:57 +0200
Mark Wolter wrote:
Hello,
I'm searching for some example code with an buffered post to a server
via
https.
What I was able to do is:
Reading from a file to a String and send the String as RequestBody:
...
File file = new File("c:\\temp\\ReportRequest.xml");
int x= fis.available();
byte b[]= new byte[x];
fis.read(b);
String content = new String(b);
post.setRequestBody(content);
...
But as this is a depracted method, I tried to read from the file via
Stream:
...
File file = new File("c:\\temp\\ReportRequest.xml");
post.setRequestEntity(new InputStreamRequestEntity(new
FileInputStream(file)));
But here I'm getting the following exception:
org.apache.commons.httpclient.ProtocolException: Unbuffered entity
enclosing
request can not be repeated.
Mike,
Consider implementing a custom request entity that encapsulates the
request body and making it repeatable . Something similar to this one:
http://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/contrib/org/apache/commons/httpclient/contrib/benchmark/FileRequestEntity.java
Hope this helps
Oleg
When using "post.setRequestEntity(new InputStreamRequestEntity(new
FileInputStream(file), file.length()));" the other side (the server) can
not
parse the xml correctly.
The error code is:
org.xml.sax.SAXParseException: Premature end of file.
Any suggestions?
Thanks!
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]