I originally wrote: > 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.
This is nonsense. I based my original assessment based on the "Allowed" methods. IIS returns PUT as a "Public" method. This is the complete wire logs generated by the OPTIONS request/response: 0 2008-11-28 14:49:42,114 [main] DEBUG httpclient.wire.header - >> "OPTIONS /upload/ HTTP/1.1[\r][\n]" 40 2008-11-28 14:49:42,154 [main] DEBUG httpclient.wire.header - >> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]" 40 2008-11-28 14:49:42,154 [main] DEBUG httpclient.wire.header - >> "Host: 192.168.4.14[\r][\n]" 40 2008-11-28 14:49:42,154 [main] DEBUG httpclient.wire.header - >> "[\r][\n]" 50 2008-11-28 14:49:42,164 [main] DEBUG httpclient.wire.header - << "HTTP/1.1 200 OK[\r][\n]" 50 2008-11-28 14:49:42,164 [main] DEBUG httpclient.wire.header - << "HTTP/1.1 200 OK[\r][\n]" 50 2008-11-28 14:49:42,164 [main] DEBUG httpclient.wire.header - << "Date: Fri, 28 Nov 2008 19:50:50 GMT[\r][\n]" 50 2008-11-28 14:49:42,164 [main] DEBUG httpclient.wire.header - << "Server: Microsoft-IIS/6.0[\r][\n]" 50 2008-11-28 14:49:42,164 [main] DEBUG httpclient.wire.header - << "MS-Author-Via: DAV[\r][\n]" 50 2008-11-28 14:49:42,164 [main] DEBUG httpclient.wire.header - << "Content-Length: 0[\r][\n]" 50 2008-11-28 14:49:42,164 [main] DEBUG httpclient.wire.header - << "Accept-Ranges: none[\r][\n]" 50 2008-11-28 14:49:42,164 [main] DEBUG httpclient.wire.header - << "DASL: <DAV:sql>[\r][\n]" 60 2008-11-28 14:49:42,174 [main] DEBUG httpclient.wire.header - << "DAV: 1, 2[\r][\n]" 60 2008-11-28 14:49:42,174 [main] DEBUG httpclient.wire.header - << "Public: OPTIONS, TRACE, GET, HEAD, DELETE, PUT, POST, COPY, MOVE, MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH[\r][\n]" 60 2008-11-28 14:49:42,174 [main] DEBUG httpclient.wire.header - << "Allow: OPTIONS, TRACE, GET, HEAD, DELETE, COPY, MOVE, PROPFIND, PROPPATCH, SEARCH, MKCOL, LOCK, UNLOCK[\r][\n]" 60 2008-11-28 14:49:42,174 [main] DEBUG httpclient.wire.header - << "Cache-Control: private[\r][\n]" 60 2008-11-28 14:49:42,174 [main] DEBUG httpclient.wire.header - << "[\r][\n]" Carlos -----Original Message----- From: Fernandez, Carlos (Contractor) Sent: Friday, November 28, 2008 2:48 PM To: [email protected] Subject: RE: PUT to iis is failing Thanks for the reply! >> Please don't post multiple times. Sorry for the double-post. I originally posted via Nabble -- big mistake ;) >> Can you upgrade to 3.1? Upgraded and the results were the same. >>You don't show the HttpClient session trace Don't know exactly what you mean by the session trace. The following is the httpclient.wire.header logs: 0 2008-11-28 14:38:48,114 [main] DEBUG httpclient.wire.header - >> "PUT /upload HTTP/1.1[\r][\n]" 30 2008-11-28 14:38:48,144 [main] DEBUG httpclient.wire.header - >> "User-Agent: EDIS3/3.0.0[\r][\n]" 30 2008-11-28 14:38:48,144 [main] DEBUG httpclient.wire.header - >> "Accept: */*[\r][\n]" 30 2008-11-28 14:38:48,144 [main] DEBUG httpclient.wire.header - >> "Pragma: no-cache[\r][\n]" 30 2008-11-28 14:38:48,144 [main] DEBUG httpclient.wire.header - >> "Cache-Control: no-cache[\r][\n]" 30 2008-11-28 14:38:48,144 [main] DEBUG httpclient.wire.header - >> "Content-Length: 208[\r][\n]" 30 2008-11-28 14:38:48,144 [main] DEBUG httpclient.wire.header - >> "Content-Type: application/octet-stream[\r][\n]" 30 2008-11-28 14:38:48,144 [main] DEBUG httpclient.wire.header - >> "Translate: f[\r][\n]" 30 2008-11-28 14:38:48,144 [main] DEBUG httpclient.wire.header - >> "Host: 192.168.4.14[\r][\n]" 30 2008-11-28 14:38:48,144 [main] DEBUG httpclient.wire.header - >> "[\r][\n]" 40 2008-11-28 14:38:48,154 [main] DEBUG httpclient.wire.header - << "HTTP/1.1 403 Forbidden[\r][\n]" 40 2008-11-28 14:38:48,154 [main] DEBUG httpclient.wire.header - << "HTTP/1.1 403 Forbidden[\r][\n]" 40 2008-11-28 14:38:48,154 [main] DEBUG httpclient.wire.header - << "Connection: close[\r][\n]" 50 2008-11-28 14:38:48,164 [main] DEBUG httpclient.wire.header - << "Date: Fri, 28 Nov 2008 19:39:56 GMT[\r][\n]" 50 2008-11-28 14:38:48,164 [main] DEBUG httpclient.wire.header - << "Server: Microsoft-IIS/6.0[\r][\n]" 50 2008-11-28 14:38:48,164 [main] DEBUG httpclient.wire.header - << "Content-Type: text/html[\r][\n]" 50 2008-11-28 14:38:48,164 [main] DEBUG httpclient.wire.header - << "Content-Length: 44[\r][\n]" 50 2008-11-28 14:38:48,164 [main] DEBUG httpclient.wire.header - << "[\r][\n]" >>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. At this point IIS server is configured to allow anonymous access. I don't provide any credentials via cadaver or BitKinex and they are both successful. However, I am not certain what they are doing underneath the hood. Carlos -----Original Message----- From: sebb [mailto:[EMAIL PROTECTED] Sent: Friday, November 28, 2008 1:56 PM To: HttpClient User Discussion Subject: Re: PUT to iis is failing On 28/11/2008, [EMAIL PROTECTED] <[EMAIL PROTECTED]> 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: [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]
