hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r672427 - /httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
Date Fri, 27 Jun 2008 23:38:31 GMT
Author: olegk
Date: Fri Jun 27 16:38:31 2008
New Revision: 672427

URL: http://svn.apache.org/viewvc?rev=672427&view=rev
Log:
Added example demonstrating the use of the ClientResponseHandler interface

Added:
    httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
  (with props)

Added: httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java?rev=672427&view=auto
==============================================================================
--- httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
(added)
+++ httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
Fri Jun 27 16:38:31 2008
@@ -0,0 +1,63 @@
+/*
+ * $HeadURL: $
+ * $Revision: $
+ * $Date: $
+ *
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.examples.client;
+
+import org.apache.http.client.ClientResponseHandler;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.BasicResponseHandler;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+/**
+ * This example demonstrates the use of the {@link ClientResponseHandler} to simply 
+ * the process of processing the HTTP response and releasing associated resources.
+ */
+public class ClientWithResponseHandler {
+
+    public final static void main(String[] args) throws Exception {
+        
+        HttpClient httpclient = new DefaultHttpClient();
+
+        HttpGet httpget = new HttpGet("http://www.google.com/"); 
+
+        System.out.println("executing request " + httpget.getURI());
+
+        // Create a response handler
+        ClientResponseHandler<String> responseHandler = new BasicResponseHandler();
+        String responseBody = httpclient.execute(httpget, responseHandler);
+        System.out.println(responseBody);
+        
+        System.out.println("----------------------------------------");
+    }
+    
+}
+

Propchange: httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientWithResponseHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message