commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From theis.megge...@se.abb.com
Subject HTTPClient
Date Tue, 29 Apr 2003 12:04:08 GMT
Hi everybody!

I'm both new to http communication, http client and I'm trying to send
files with
authentication. However, when sending the request, the request header does
not contain
any authorization header. Shouldn't it? How does it work?
Down below is my code:

          if (this.isAuthorisation())
          {
               if (user == null || password == null)
               {
                    throw new Exception("Authentication is set to true, but
user or password is null");
               }

               client.getState().setCredentials(null, new
UsernamePasswordCredentials(user, password));
               filePost.setDoAuthentication(true);
          }
          FileInputStream stream = new FileInputStream(file);

          filePost.setRequestBody(stream);
          filePost.setRequestHeader("Content-length",
String.valueOf(file.length()));
          status = client.executeMethod(filePost);
          Header[] header = filePost.getRequestHeaders();
          for (int i=0; i < header.length; i++)
          {

               System.out.println(header[i].getName() + " " +
header[i].getValue());
          }
          stream.close();
          statusText = filePost.getStatusText();
          filePost.releaseConnection();
          filePost = null;
          return status;
     }

Here is the reqeust header:
POST http://<host>:5555/collaborator/sap45/fileUpload HTTP/1.1
Content-length: 9411
Host: <host>:5555
User-Agent: Jakarta Commons-HttpClient/2.0M1
X-tid: test2
Content-type: application/x-idoc

Using commons-httpclient-2.0-alpha2

Thanks in advance,

Theis.


Mime
View raw message