OutOfMemory if using PUT

2004-03-17 Thread martin hilpert
Hello,
i using the HttpClient in a Java Applet but
if i transfer a file larger then 32MB i get a OutOfMemory.

does some others has the same bug?

greetz from Germany

Martin

Re: OutOfMemory if using PUT

2004-03-17 Thread Ortwin Glück
Martin,

please have a look at this example:

http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/ChunkEncodedPost.java?rev=1.4.2.1only_with_tag=HTTPCLIENT_2_0_BRANCHview=auto

(link may be wrapped)

Kind regards

Ortwin Glück

martin hilpert wrote:

Hello,
i using the HttpClient in a Java Applet but
if i transfer a file larger then 32MB i get a OutOfMemory.
does some others has the same bug?

greetz from Germany

Martin
--
 _
 NOSE applied intelligence ag
 ortwin glück  [www]  http://www.nose.ch
 software engineer [email] [EMAIL PROTECTED]
 hardturmstrasse 171   [pgp id]   0x81CF3416
 8005 zürich   [office]  +41-1-277 57 35
 switzerland   [fax] +41-1-277 57 12
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: OutOfMemory if using PUT

2004-03-17 Thread martin hilpert
Hallo Ortwin so schnell findet man sich wieder,
du hast in der einen Java NG geantwortet


http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/Ch
unkEncodedPost.java?rev=1.4.2.1only_with_tag=HTTPCLIENT_2_0_BRANCHview=aut
o



gruß martin



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



RE: OutOfMemory if using PUT

2004-03-17 Thread Kalnichevski, Oleg

Martin,
The problem is most likely caused by the PUT method buffering the request body in 
order to determine its length

You can avoid this problem by 

(1) using chunk-encoding

http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/ChunkEncodedPost.java?rev=1.4.2.1only_with_tag=HTTPCLIENT_2_0_BRANCHview=markup

(2) explicitly specifying the content length

http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/UnbufferedPost.java?rev=1.2.2.1only_with_tag=HTTPCLIENT_2_0_BRANCHview=markup

Oleg

-Original Message-
From: martin hilpert [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 17, 2004 11:09
To: [EMAIL PROTECTED]
Subject: OutOfMemory if using PUT


Hello,
i using the HttpClient in a Java Applet but
if i transfer a file larger then 32MB i get a OutOfMemory.

does some others has the same bug?

greetz from Germany

Martin

***
The information in this email is confidential and may be legally privileged.  Access 
to this email by anyone other than the intended addressee is unauthorized.  If you are 
not the intended recipient of this message, any review, disclosure, copying, 
distribution, retention, or any action taken or omitted to be taken in reliance on it 
is prohibited and may be unlawful.  If you are not the intended recipient, please 
reply to or forward a copy of this message to the sender and delete the message, any 
attachments, and any copies thereof from your system.
***

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



Re: OutOfMemory if using PUT

2004-03-17 Thread martin hilpert
Hello Oleg,

 The problem is most likely caused by the PUT method buffering the request
body in order to determine its length

that means there is no work around WITH PUT ?


 You can avoid this problem by

 (1) using chunk-encoding


http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/Ch
unkEncodedPost.java?rev=1.4.2.1only_with_tag=HTTPCLIENT_2_0_BRANCHview=mar
kup

 (2) explicitly specifying the content length


http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/Un
bufferedPost.java?rev=1.2.2.1only_with_tag=HTTPCLIENT_2_0_BRANCHview=marku
p

that are both POST requests?



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



Re: OutOfMemory if using PUT

2004-03-17 Thread Ortwin Glück


martin hilpert wrote:
that means there is no work around WITH PUT ?
The two alternatives ARE the work around!

that are both POST requests?
The same applies to PUT methods as well as PUT basically works the same 
as POST.

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


Re: OutOfMemory if using PUT

2004-03-17 Thread martin hilpert
ok first thank it work now with files larger 32mb,
but there is still a another problem.

if the user transfer a large file like 32MB over a normal DSL connection
(128kbit up / 796 kbit down)

how could i find out how many bytes are send?

is there anyway?

martin



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



Re: OutOfMemory if using PUT

2004-03-17 Thread martin hilpert
Hi Ortwin,
 Not from within HttpClient directly. You can however simply wrap your 
 stream and count the bytes read through the respective methods.
 how can i wrap it?
any sampel code?

thx

martin


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



Re: OutOfMemory if using PUT

2004-03-17 Thread Ortwin Glück


martin hilpert wrote:

Hi Ortwin,

Not from within HttpClient directly. You can however simply wrap your 
stream and count the bytes read through the respective methods.
 how can i wrap it?
any sampel code?
Errm... Ever heard of the java.io.FilterInputStream class? It is 
intended to be a base class for such a thing linke you need. If you are 
using Swing you can just use javax.swing.ProgressMonitorInputStream.

O.

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


Re: OutOfMemory if using PUT

2004-03-17 Thread martin hilpert
Hi,
yes i heard about that class.
no i dont use any swing control,
i use awt.


 Errm... Ever heard of the java.io.FilterInputStream class? It is 
 intended to be a base class for such a thing linke you need. If you are 
 using Swing you can just use javax.swing.ProgressMonitorInputStream.
i dont understand how i can monitor the stream.

HttpClient client = new HttpClient();
PutMethod put = new PutMethod(zielurl);
FileInputStream fin =new FileInputStream(C:\test.jpg);
put.setRequestBody(fin);
put.setRequestContentLength(PutMethod.CONTENT_LENGTH_CHUNKED);
client.executeMethod(put);
System.out.print(put.getResponseBodyAsString());
put.releaseConnection();




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



Re: OutOfMemory if using PUT

2004-03-17 Thread Ortwin Glück


martin hilpert wrote:
i dont understand how i can monitor the stream.

HttpClient client = new HttpClient();
PutMethod put = new PutMethod(zielurl);
FileInputStream fin =new FileInputStream(C:\test.jpg);
  MonitorInputStream min = new MonitorInputStream(fin);
put.setRequestBody(fin);
put.setRequestContentLength(PutMethod.CONTENT_LENGTH_CHUNKED);
client.executeMethod(put);
System.out.print(put.getResponseBodyAsString());
put.releaseConnection();
class MonitorInputStream extends FilterInputStream {

   public MonitorInputStream(InputStream in) {
  super(in);
   }
   ...

   public  int  read(byte[] b, int off, int len) {
 int bytesRead = super.read(b, off, len);
 ... do what you like with bytesRead now ...

 return bytesRead;
   }
}

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