Return-Path: Delivered-To: apmail-jakarta-httpclient-user-archive@www.apache.org Received: (qmail 31158 invoked from network); 26 Oct 2004 21:30:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 26 Oct 2004 21:30:17 -0000 Received: (qmail 38619 invoked by uid 500); 26 Oct 2004 21:30:16 -0000 Delivered-To: apmail-jakarta-httpclient-user-archive@jakarta.apache.org Received: (qmail 38601 invoked by uid 500); 26 Oct 2004 21:30:16 -0000 Mailing-List: contact httpclient-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: "HttpClient User Discussion" Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-user@jakarta.apache.org Received: (qmail 38587 invoked by uid 99); 26 Oct 2004 21:30:16 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from [195.186.1.74] (HELO mail1.bluewin.ch) (195.186.1.74) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 26 Oct 2004 14:30:15 -0700 Received: from xbox.localdomain (83.76.137.65) by mail1.bluewin.ch (Bluewin AG 7.0.030.2) id 416E82A900159995 for httpclient-user@jakarta.apache.org; Tue, 26 Oct 2004 21:30:13 +0000 Received: from [192.168.0.3] (unknown [192.168.0.3]) by xbox.localdomain (Postfix) with ESMTP id 76BB1B6ECA for ; Tue, 26 Oct 2004 23:30:13 +0200 (CEST) Subject: Re: very simple problem... how to post data to an HttpConnection... From: Oleg Kalnichevski To: httpclient-user@jakarta.apache.org In-Reply-To: <20041026205206.48005.qmail@web51510.mail.yahoo.com> References: <20041026205206.48005.qmail@web51510.mail.yahoo.com> Content-Type: text/plain Message-Id: <1098826212.2675.36.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 26 Oct 2004 23:30:12 +0200 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Mike, In fact, we strongly discourage the direct use of HttpConnection class. The preferred way is to let the connection manager take care of the HTTP connection business. Unless you have a real reason to use HttpConnection class directly, I'd recommend that you use HttpClient instead Something like that: ===================================================================== HttpClient client = new HttpClient(); PostMethod httppost = new PostMethod("http://www.whatever.com"); File file = new File(args[0]); httppost.setRequestBody(new FileInputStream(file)); httppost.setRequestContentLength((int)file.length()); try { client.executeMethod(httppost); if (httppost.getStatusCode() != HttpStatus.SC_OK) { System.out.println("Unexpected failure: " + httppost.getStatusLine()); } System.out.println(httppost.getResponseBodyAsString()); } finally { httppost.releaseConnection(); } ===================================================================== BTW, you are the first ever user to post to the httplclient-user list ;-) Cheers, Oleg On Tue, 2004-10-26 at 22:52, Mike Y wrote: > As you might guess from the subject, I'm new here > > I'm attempting to use the 2.0.2 version of this > project to create a connection, post data to it, and > read the results, or at least get a Stream of output > that I can pass someplace else. > > I've been reading the Javadocs and tutorials for the > last hour at least, the tutorials seem to reference an > HttpMethod class which can't actually be found in the > Javadocs or distribution. > > So, I'm not sure what I'm supposed to do. I have: > > 1. String postRequest = " ... "; > 2. HttpConnection c = new HttpConnection > ("http://somesite/somedynamicpage.asp", 80); > 3. c.setConnectionTimeout(someTimeoutValue); > > 4. --- Need to post my request to my connection -- > > return c.getResponseInputStream(); > > I would greatly appreciate any help here. I hope this > is not a stupid question. I saw and read the docs on > the PostMethod, but it's not clear to me how this > class interacts with HttpConnection. This is likely > the result of my own mental deficiencies. > > For what it is worth, the tutorial I was looking at > was here: > > http://cvs.apache.org/viewcvs.cgi/jakarta-commons/httpclient/src/examples/Attic/CustomHttpConnection.java?only_with_tag=HTTPCLIENT_2_0_BRANCH&view=markup). > > --Mike > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail Address AutoComplete - You start. We finish. > http://promotions.yahoo.com/new_mail > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: httpclient-user-help@jakarta.apache.org