Return-Path: Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: (qmail 70644 invoked from network); 28 Nov 2008 18:56:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Nov 2008 18:56:27 -0000 Received: (qmail 55455 invoked by uid 500); 28 Nov 2008 18:56:38 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 55425 invoked by uid 500); 28 Nov 2008 18:56:38 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 55414 invoked by uid 99); 28 Nov 2008 18:56:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Nov 2008 10:56:38 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=NORMAL_HTTP_TO_IP,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 74.125.78.146 as permitted sender) Received: from [74.125.78.146] (HELO ey-out-1920.google.com) (74.125.78.146) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Nov 2008 18:55:11 +0000 Received: by ey-out-1920.google.com with SMTP id 4so611183eyk.10 for ; Fri, 28 Nov 2008 10:55:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=1F7aqD9cH7sj/lBnW+EcRALifke8k25QEZQ9G59I/zI=; b=mPO1QrHOXs7x15aBp1HGR4Kcac4bmw9+z7URMHvwyLJ7TIAMG49B2wOHumlnnK0One Oaq9kEkIcAEXBJ0E+dTEP5yxrz5+rAzcNpgkRrcUuvA8YTUhX1RnFTWABGHccBUAwvef tKT54yCaL5JM6W8slHZuWmN7Tmy3FIWLHKlb4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=IGHeT9fLwT/CRcl99sxp0wQ1EWoZZie0HIg7GbhK2yWzuTUPXc5r7bbHCbdiY8ybkB WZiO3KQOBgPOmjpLJTkij6j+j+qUejgkPLbVKNUBdqIi9nVAM8qZlAqd+hNDkJ25ndjU j+RGW/lPOQeLtV8MRq54ngZx70cNqZKEoA7bk= Received: by 10.86.93.19 with SMTP id q19mr5476027fgb.62.1227898547051; Fri, 28 Nov 2008 10:55:47 -0800 (PST) Received: by 10.86.65.7 with HTTP; Fri, 28 Nov 2008 10:55:46 -0800 (PST) Message-ID: <25aac9fc0811281055l16baf5acl44333540c5fd393c@mail.gmail.com> Date: Fri, 28 Nov 2008 18:55:46 +0000 From: sebb To: "HttpClient User Discussion" Subject: Re: PUT to iis is failing In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Checked: Checked by ClamAV on apache.org On 28/11/2008, 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