hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: PUT to iis is failing
Date Fri, 28 Nov 2008 18:55:46 GMT
On 28/11/2008, Carlos.Fernandez@usitc.gov <Carlos.Fernandez@usitc.gov> wrote:
> I need to PUT files onto an IIS v6 server.

Please don't post multiple times.

>  My attempts to PUT to an IIS fail with a 403 response code.
>
>  Attempts to PUT the same file to the same IIS URI in cadaver or BitKinex
>  are successful.
>
>  I am using IIS 6.  I assume that webDAV is set up properly because
>  cadaver and BitKinex are successful.
>  I am using HTTP-client v 3.0.1

This is fairly old.

Can you upgrade to 3.1?

>  Java 1.5 on windows XP sp2
>
>  This is my HTTP put test.
>
>     @Override
>     protected void setUp() throws Exception {
>         // TODO Auto-generated method stub
>         super.setUp();
>         client = new HttpClient();
>         host = "192.168.4.14";
>         uriString = MessageFormat.format("http://{0}/upload", host);
>     }
>
>     public void testHttpClientPut() throws Exception {
>         File pdf = new
>  File("C:\\Temp\\edis3-dev\\cd\\attachments\\1f6135e5-5ec3-435e-82d3-5395
>  7e39fc83\\-95097967_-66622204.pdf");
>         PutMethod method = new PutMethod(uriString);
>         method.setRequestHeader("Host", host);
>         method.setRequestHeader("User-Agent", "EDIS3/3.0.0");
>         method.setRequestHeader("Accept", "*/*");
>         method.setRequestHeader("Pragma", "no-cache");
>         method.setRequestHeader("Cache-Control", "no-cache");
>
>         method.setRequestHeader("Content-Length",
>  String.valueOf(pdf.length()));
>         method.setRequestHeader("Content-Type",
>  "application/octet-stream");
>         method.setRequestHeader("Translate", "f");
>
>         InputStreamRequestEntity requestEntity
>             = new InputStreamRequestEntity(new FileInputStream(pdf));
>
>         method.setRequestEntity(requestEntity);
>
>         executeMethod(method);
>
>     }
>
>     private void executeMethod(HttpMethod method) throws IOException,
>             HttpException {
>         try {
>             Header[] headers = method.getRequestHeaders();
>
>             outputHeaders(headers, "REQUEST HEADERS");
>
>             int result = client.executeMethod(method);
>             assertTrue("response was: " + result, 200 <= result &&
>  result < 300);
>         } finally {
>             method.releaseConnection();
>         }
>     }
>
>  Here are the HTTP headers for BitKinex
>
>  <<< PUT /upload/-95097967_-66622204.pdf HTTP/1.1
>  <<< Host: 192.168.4.14
>  <<< User-Agent: BitKinex/3.0.4
>  <<< Accept: */*
>  <<< Pragma: no-cache
>  <<< Cache-Control: no-cache
>  <<< Cookie: ASPSESSIONIDSATRBDAR=GEHBABIDLOEICKBKHHHNPBHA
>  <<< Content-Length: 208
>  <<< Content-Type: application/octet-stream
>  <<< Translate: f
>  >>> HTTP/1.1 201 Created
>  >>> Date: Fri, 28 Nov 2008 17:30:40 GMT
>  >>> Server: Microsoft-IIS/6.0
>  >>> Location: http://192.168.4.14/upload/-95097967_-66622204.pdf
>  >>> Content-Length: 0
>  >>> Allow: OPTIONS, TRACE, GET, HEAD, DELETE, PUT, COPY, MOVE, PROPFIND,
>  PROPPATCH, SEARCH, LOCK, UNLOCK
>
>  CADAVER SESSION
>  >>>$ cadaver http://192.168.4.14/upload
>  >>>dav:/upload/> PUT another.test.txt
>  >>>Uploading another.test.txt to `/upload/another.test.txt': succeeded.
>  >>>dav:/upload/>
>
>  I can't tell if this is some IIS oddity.  When i request the options
>  from the server PUT is not listed (advertised methods are: [OPTIONS,
>  TRACE, GET, HEAD, DELETE, COPY, MOVE, PROPFIND, PROPPATCH, SEARCH,
>  MKCOL, LOCK, UNLOCK]).  However, when BitKinex has its PUT successfully
>  returned the allowed options header does include PUT.
>
>  Any ideas?

403 means forbidden

You don't show the HttpClient session trace, but an obvious omission
from the code is any attempt to set a cookie or login or provide any
other way to authenticate the upload, so it's not surprising that IIS
complains.

>  Carlos
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>  For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message