Re: Problem posting file and deleting it afterwards

2003-03-16 Thread Oleg Kalnichevski
Olaf,
The bug has been already fixed no that long ago. Thanks for pointing it
out, anyways, as it made me think that the code should probably be even
more protective:

protected void sendData(OutputStream out) throws IOException {
LOG.trace(enter sendData(OutputStream out));
if (lengthOfData() == 0) {

// this file contains no data, so there is nothing to send.
// we don't want to create a zero length buffer as this will
// cause an infinite loop when reading.
LOG.debug(No data to send.);
return;
}

byte[] tmp = new byte[4096];
InputStream instream = source.createInputStream();
try {
int len;
while ((len = instream.read(tmp)) = 0) {
out.write(tmp, 0, len);
}
} finally {
// we're done with the stream, close it
instream.close();
}
}

Cheers

Oleg  

On Sat, 2003-03-15 at 17:40, [EMAIL PROTECTED] wrote:
 I send a file on the harddisk using class FilePart and everything works
 fine.
 But it is just a temporary file which should be deleted afterwards sending
 it, but File.delete() fails and the file remains on the disk (based on
 alpha 3). As far as I found out, the method sendData creates an
 inputStream from the file, but did not close it at any time, so the file is
 still locked after sending. So my fix is to close this InputStream after
 all data is send (line marked with +). I do not know if this has any side
 effects or other problems, but my problem would be fixed.
 
 What do you think?
 
 Regards,
 Olaf
 
 
protected void sendData(OutputStream out) throws IOException {
   LOG.trace(enter sendData(OutputStream out));
   if (lengthOfData() == 0) {
 
// this file contains no data, so there is nothing to send.
// we don't want to create a zero length buffer as this will
// cause an infinite loop when reading.
LOG.debug(No data to send.);
return;
  }
 
  byte[] tmp = new byte[4096];
  InputStream instream = source.createInputStream();
 
  int len;
  while ((len = instream.read(tmp)) = 0) {
 out.write(tmp, 0, len);
  }
 
 +   instream.close();
   }
 
 
 
 
 
 -
 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]



HttpClient contrib package established

2003-03-16 Thread Oleg Kalnichevski
Folks

I have taken liberty of committing the very first components to the our
muck spoken about HttpClient contribution package.

I have to say it has become a bit of a problem that patches cannot be
posted as attachments to the mailing list. So, even though I am
perfectly aware of the fact that these components have not been
thoroughly reviewed, I could not think of a better way of making them
available for review (apart from creating a fake bug report or mailing
them directly to all HttpClient contributors). I hope you all find this
compromise justified

Cheers

Oleg 






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



Re: Logging guide fixed

2003-03-16 Thread Jeff Dever
Ok,

I'm pinned in Victoria right now, will do when I arrive on Monday or 
Tuesday.

Oleg Kalnichevski wrote:

Jandalf,
Logging guide has been fixed. Ideally the web site should be redeployed
for the fix to take effect
Cheers
Oleg
On Fri, 2003-03-14 at 09:59, Kalnichevski, Oleg wrote:
 

Tom
Thanks for pointing it out
Cheers
Oleg
-Original Message-
From: Tom Samplonius [mailto:[EMAIL PROTECTED]
Sent: Freitag, 14. März 2003 08:06
To: Commons HttpClient Project
Subject: RE: problem with post


On Thu, 13 Mar 2003 [EMAIL PROTECTED] wrote:

   

System.setProperty(
org.apache.commons.logging.simplelog.log.httpclient.wire , debug);
 

 I had this problem too.  You copied this right off the website, didn't
you?  Well, there is an extra space after .wire that prevents this from
doing anything.  Take it out, and it will activate wirelogging.
 Someone might want to fix the website.

Tom

-
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]
   



-
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]


Re: Logging guide fixed

2003-03-16 Thread Oleg Kalnichevski
Hi Jandalf
No worries, it can wait a day or two. 
This said, it would be cool if you could give me your feedback on these
two bugs :-)

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17947 
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10817

I am REALLY determined to have as many bug closed by the end of month as
humanly possible, and I'll spare no effort or time on my part to make
that happen.

Cheers

Oleg  

On Sun, 2003-03-16 at 21:22, Jeff Dever wrote:
 Ok,
 
 I'm pinned in Victoria right now, will do when I arrive on Monday or 
 Tuesday.
 
 
 Oleg Kalnichevski wrote:
 
 Jandalf,
 Logging guide has been fixed. Ideally the web site should be redeployed
 for the fix to take effect
 Cheers
 Oleg
 
 
 On Fri, 2003-03-14 at 09:59, Kalnichevski, Oleg wrote:
   
 
 Tom
 Thanks for pointing it out
 Cheers
 Oleg
 
 -Original Message-
 From: Tom Samplonius [mailto:[EMAIL PROTECTED]
 Sent: Freitag, 14. März 2003 08:06
 To: Commons HttpClient Project
 Subject: RE: problem with post
 
 
 
 On Thu, 13 Mar 2003 [EMAIL PROTECTED] wrote:
 
 
 
 System.setProperty(
 org.apache.commons.logging.simplelog.log.httpclient.wire , debug);
   
 
   I had this problem too.  You copied this right off the website, didn't
 you?  Well, there is an extra space after .wire that prevents this from
 doing anything.  Take it out, and it will activate wirelogging.
 
   Someone might want to fix the website.
 
 Tom
 
 
 -
 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]
 
 
 
 
 
 -
 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]
 


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



[PATCH] switch redirect to use URI

2003-03-16 Thread Michael Becke
Again, but with the patch inlined.

On Sunday, March 16, 2003, at 10:20 PM, Michael Becke wrote:

Attached is a patch that switches redirect processing from using URL  
to URI.  The only reason for doing this is to avoid setting the system  
property java.protocol.handler.pkgs to  
com.sun.net.ssl.internal.www.protocol when using HTTPS in pre 1.4  
JVMs.  Please let me know if you think this is worthwhile.

Mike

Index: src/java/org/apache/commons/httpclient/HttpMethodBase.java
===
RCS file:  
/home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/ 
httpclient/HttpMethodBase.java,v
retrieving revision 1.123
diff -u -r1.123 HttpMethodBase.java
--- src/java/org/apache/commons/httpclient/HttpMethodBase.java	13 Mar  
2003 17:51:28 -	1.123
+++ src/java/org/apache/commons/httpclient/HttpMethodBase.java	17 Mar  
2003 03:14:40 -
 -68,14 +68,12 
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InterruptedIOException;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.HashSet;
 import java.util.Set;

-import org.apache.commons.httpclient.cookie.MalformedCookieException;
 import org.apache.commons.httpclient.cookie.CookiePolicy;
 import org.apache.commons.httpclient.cookie.CookieSpec;
+import org.apache.commons.httpclient.cookie.MalformedCookieException;
 import org.apache.commons.httpclient.protocol.Protocol;
 import org.apache.commons.httpclient.util.URIUtil;
 import org.apache.commons.logging.Log;
 -128,7 +126,7 
  * author a href=mailto:[EMAIL PROTECTED]dIon Gillard/a
  * author a href=mailto:[EMAIL PROTECTED]Jeff Dever/a
  * author a href=mailto:[EMAIL PROTECTED]Davanum Srinivas/a
- * author Ortwin Gl
+ * author Ortwin Glck
  * author Eric Johnson
  * author Michael Becke
  * author a href=mailto:[EMAIL PROTECTED]Oleg Kalnichevski/a
 -1074,33 +1072,37 
 //rfc2616 demands the location value be a complete URI
 //Location   = Location : absoluteURI
-URL redirectUrl = null;
-URL currentUrl = null;
+URI redirectUri = null;
+URI currentUri = null;
 try {
-currentUrl = new URL(conn.getProtocol().getScheme(),
-conn.getHost(), conn.getPort(), this.getPath());
-redirectUrl = new URL(location);
-} catch (MalformedURLException e) {
-if (isStrictMode()) {
-LOG.warn(Redirected location ' + location
-+ ' is not acceptable in strict mode);
-return false;
-} else { //location is incomplete, use current values for  
defaults
-try {
-LOG.debug(Redirect URL is not absolute - parsing  
as relative);
-redirectUrl = new URL(currentUrl, location);
-} catch (MalformedURLException ex) {
-LOG.warn(Redirected location ' + location
-+ ' is malformed);
+currentUri = new URI(
+conn.getProtocol().getScheme(),
+null,
+conn.getHost(),
+conn.getPort(),
+this.getPath()
+);
+redirectUri = new URI(location.toCharArray());
+if (redirectUri.isRelativeURI()) {
+if (isStrictMode()) {
+LOG.warn(Redirected location ' + location
++ ' is not acceptable in strict mode);
 return false;
+} else {
+//location is incomplete, use current values for  
defaults
+LOG.debug(Redirect URI is not absolute - parsing  
as relative);
+redirectUri = new URI(currentUri, redirectUri);
 }
 }
+} catch (URIException e) {
+LOG.warn(Redirected location ' + location + ' is  
malformed);
+return false;
 }

 //check for redirect to a different protocol, host or port
 try {
-checkValidRedirect(currentUrl, redirectUrl);
+checkValidRedirect(currentUri, redirectUri);
 } catch (HttpException ex) {
 //LOG the error and let the client handle the redirect
 LOG.warn(ex.getMessage());
 -1110,51 +1112,56 
 //update the current location with the redirect location.
 //avoiding use of URL.getPath() and URL.getQuery() to keep
 //jdk1.2 comliance.
-setPath(URIUtil.getPath(redirectUrl.toString()));
-setQueryString(URIUtil.getQuery(redirectUrl.toString()));
+setPath(redirectUri.getEscapedPath());
+setQueryString(redirectUri.getEscapedQuery());
 if (LOG.isDebugEnabled()) {
-LOG.debug(Redirecting from ' +  
currentUrl.toExternalForm()
-+ ' to ' + redirectUrl.toExternalForm());
+LOG.debug(Redirecting from ' + currentUri.getEscapedURI()
+

DO NOT REPLY [Bug 17947] - Need setURI() methods in HttpMethod interface

2003-03-16 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17947.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17947

Need setURI() methods in HttpMethod interface

[EMAIL PROTECTED] changed:

   What|Removed |Added

   Target Milestone|2.0 Beta 1  |2.1 Final



--- Additional Comments From [EMAIL PROTECTED]  2003-03-17 07:01 ---
It is getting a little late in the development cycle for this enhancement as
changing HttpMethodBase.  URI is posed to move to its own subpackage where this
change can be made after 2.0 is released.

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



DO NOT REPLY [Bug 10817] - Provide more Example Code

2003-03-16 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10817.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10817

Provide more Example Code





--- Additional Comments From [EMAIL PROTECTED]  2003-03-17 07:06 ---
The only issue left is to make the required change to build.xml

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