W3C home > Mailing lists > Public > www-jigsaw@w3.org > January to February 2001

my PUT's are being scrambled, any suggestions?

From: Bob Schader <rschader@product-des.com>
Date: Sun, 25 Feb 2001 14:46:07 -0500
Message-ID: <3A9960FF.53380E22@product-des.com>
To: Jigsaw List <www-jigsaw@w3.org>
Intro to my problem:
I finally thought I found a way to monitor HTTP PUT uploads
by using the w3c client java library included with Winie and
also part of Jigsaw, so I could implement a pure java
upload app, as opposed to my current method of incorporating
libcurl and using native calls. I previously found the
standard HttpURLConnection classes in java inadaquate for this
purpose and had other problems trying to use the HttpClient
library from www.innovations.ch

After studying the source code to Winie's JW and JWPut classes,
and reading the Javadocs for the Jigsaw client library, I tried
to implement it, and thought I was doing pretty good at it,
until I decided to verify that my uploaded files were OK, which
I discovered they weren't. So, I tried backing up, removing
StreamMonitors, ByteCountInputStreams, etc, to see if those
items were causing the problems, which they weren't. I now have 
the following compacted code, that seems to be uploading files
with no errors, but the zip files I am uploading are being
corrupted. I am 99% certain it is not on the server side, as
I have never had any other problems uploading files using PUT.

Hopefully someone more versed in the client library code could
point out something I may have missed here:

try
{
 HttpCredential credential = null;
 HttpManager manager = HttpManager.getManager() ;
 org.w3c.www.protocol.http.Request request = manager.createRequest();
 request.setObserver(this);
 request.setMethod("PUT");
 request.setURL(new URL(CompleteURL));
 request.setValue("Content-Type", "application/octet-stream");
 request.setValue("Content-Length", String.valueOf(localFlen));
 Base64Encoder encoder = new Base64Encoder(AuthUser + ":" 
      + AuthPasswd);
 credential = HttpFactory.makeCredential("Basic");
 credential.setAuthParameter("cookie", encoder.processString());
 request.setAuthorization(credential);
 request.setExpect("100-continue");
            
 InputStream in = new FileInputStream(localFile);

 if(in != null) 
 {
   request.setOutputStream(in);
 }
 if (request != null) {
   org.w3c.www.protocol.http.Reply reply =
      manager.runRequest(request);
 } else {
   System.out.println("request object is null!");
 }
} catch (HttpException ex) {
  System.out.println(ex.getMessage());
} catch(FileNotFoundException fnfex) {
  System.out.println(fnfex.getMessage());
} catch (MalformedURLException mfuex) {
  System.out.println(mfuex.getMessage());
} catch (IOException ioex) {
  System.out.println(ioex.getMessage());
}

Thanks in advance,
Bob Schader
Received on Sunday, 25 February 2001 14:46:58 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:35 GMT