Return-Path: Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: (qmail 10795 invoked from network); 22 Apr 2008 14:54:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Apr 2008 14:54:23 -0000 Received: (qmail 82045 invoked by uid 500); 22 Apr 2008 14:54:23 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 82020 invoked by uid 500); 22 Apr 2008 14:54:23 -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 82009 invoked by uid 99); 22 Apr 2008 14:54:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Apr 2008 07:54:23 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of piersony@gmail.com designates 64.233.170.185 as permitted sender) Received: from [64.233.170.185] (HELO rn-out-0910.google.com) (64.233.170.185) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Apr 2008 14:53:39 +0000 Received: by rn-out-0910.google.com with SMTP id a46so740095rne.9 for ; Tue, 22 Apr 2008 07:53:52 -0700 (PDT) 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:references; bh=2UmIoVMt1Fr18b0Nspbt2lyK4IHtwbG7bJp9/B+D150=; b=oPW1fdVq9fZemcFe7/AkZrp23rj/iVyqpoG9JdjgOhMI7DMeOHwyjyWaAmdr3fZfp+BcsyfraReobIAP5631AcvvYJ8anu5N69miBy2ggiPEkjLEZPjFrTIYHHTl/T2X5WcSGITE/EG+hFFDEOvji2dvvLhjdts+7c6aNt4FrXs= 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:references; b=QKsF6UwbPCT3zBI77D07oTZm4sHcZ0Xx8u+A7xiwj1wPx3RVgi1LLG2ZmFnwH3RfJYMatvHDhm0c5qIDWa1qxENG7d8rxQ0iYawWFIY/TLgdow29PmHbok79HLMsOvonxUB+E6MW4lUmOsmlDljoZq/Rl1nuWTEP6byRxhnVktA= Received: by 10.140.251.1 with SMTP id y1mr156848rvh.292.1208876031818; Tue, 22 Apr 2008 07:53:51 -0700 (PDT) Received: by 10.140.132.15 with HTTP; Tue, 22 Apr 2008 07:53:51 -0700 (PDT) Message-ID: <60d6743e0804220753s3f5e8435o2ad230dbe64a7305@mail.gmail.com> Date: Tue, 22 Apr 2008 16:53:51 +0200 From: "Yannick PIERSON" To: "HttpClient User Discussion" Subject: Re: store file In-Reply-To: <480DF009.4050808@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_15223_12694788.1208876031823" References: <60d6743e0804220226t53e985eu16dc0fe61bc107f8@mail.gmail.com> <60d6743e0804220550o29b6ff41p7af5ae6d19eebe94@mail.gmail.com> <480DF009.4050808@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_15223_12694788.1208876031823 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, Ok thanks a lot for previous message. I get an error when I'm executing my code : connection is aborted. I've searched in many documents but I've found nothing. And many topics are not resolved. My aim is to put a file on a IIS remote server. My code : HttpClient client = new HttpClient(); Credentials credentials = new NTCredentials("user", "pwd", "homecomputer ", "WORKGROUP"); HttpState state = client.getState(); state.setCredentials(null, null, credentials); /* List authPrefs = new ArrayList(1); // I think I don't need that if I use NTCredentials authPrefs.add(AuthPolicy.NTLM); client.getParams().setParameter(AuthPolicy.NTLM, authPrefs); */ client.getParams().setAuthenticationPreemptive(true); PutMethod put = new PutMethod("http://computer_name/webdav_acces"); put.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); // put.setDoAuthentication(true); File file = new File("c:\\temp\\pdf_file.pdf"); put.setRequestEntity(new FileRequestEntity(file, "application/octet-stream")), // I tried too with "text/plain; charset=UTF-8" client.executeMethod(put); Trace of the exception : java.net.SocketException: Software caused connection abort: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at java.io.BufferedOutputStream.write(BufferedOutputStream.java:105) at org.apache.commons.httpclient.WireLogOutputStream.write(WireLogOutputStream.java:68) at org.apache.commons.httpclient.methods.FileRequestEntity.writeRequest(FileRequestEntity.java:76) at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499) at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) at javaapplication1.HttpClt.myPost(HttpClt.java:111) at javaapplication1.Main.main(Main.java:42) Thanks, Regards. Yannick 2008/4/22, Thierry Boileau : > > Hello, > > PUT means that you send the new representation of a resource (identified > by its URI). If this resource does not exists, you create it with the > provided representation. If it exists you replace its current > representation. > POST does not have such a precise definition, and then can be used to > store file also. > > best regards, > Thierry Boileau > > Hi, > > To store a file must I execute post or put method (if I understand well, > > both work, but put method is better) ? > > > > Please help > > Thanks, > > Regards. > > > > Yannick > > > > 2008/4/22, Yannick PIERSON : > > > > > > > Hi, > > > I don't understand why it doesn't work. I try many examples (for > > > example > > > in a previous message with put method). > > > > > > HttpClient client = new HttpClient(); > > > Credentials credentials = new NTCredentials("user", "pwd", > > > "homecomputer > > > ", "WORKGROUP"); > > > HttpState state = client.getState(); > > > state.setCredentials(null, null, credentials); > > > > > > PostMethod httppost = new PostMethod(" > > > http://computer_name/webdav_acces"); > > > // Is it the good path ????????????????????????????? > > > > > > File file = new File("c:\\temp\\my_pdf.pdf"); > > > httppost.setRequestEntity(new InputStreamRequestEntity(new > > > FileInputStream(file), file.length())); > > > // httppost.setContentChunked(true); > > > > > > client.executeMethod(httppost); > > > > > > With this code I get this error : > > > org.apache.commons.httpclient.ProtocolException: Unbuffered entity > > > enclosing request can not be repeated. > > > at > > > > > > org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:487) > > > at > > > > > > org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114) > > > at > > > > > > org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096) > > > at > > > > > > org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) > > > at > > > > > > org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) > > > at > > > > > > org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) > > > at > > > > > > org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323) > > > at javaapplication1.HttpClt.myPost(HttpClt.java:94) > > > at javaapplication1.Main.main(Main.java:42) > > > > > > Thanks in advance, > > > Regards. > > > > > > Yannick > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org > For additional commands, e-mail: httpclient-users-help@hc.apache.org > > ------=_Part_15223_12694788.1208876031823--