|
||||||||
Google App Engine: URL Fetch
SAME AS Standard Java (well, replaces java.net.URLConnection with a GAE service-based implementation) --- but, for programmer is the sameimport java.net.URL;
URL Fetch Limits
GAE URL Fectch in Java setting parameters -- use low level GAE api classes
import java.net.URL; import java.net.MalformedURLException; import com.google.appengine.api.urlfetch.FetchOptions; import com.google.appengine.api.urlfetch.HTTPMethod; import com.google.appengine.api.urlfetch.HTTPRequest; import com.google.appengine.api.urlfetch.HTTPResponse; import com.google.appengine.api.urlfetch.ResponseTooLargeException; import com.google.appengine.api.urlfetch.URLFetchService; import com.google.appengine.api.urlfetch.URLFetchServiceFactory; // ... try { URL url = new URL("http://ae-book.appspot.com/blog/atom.xml/"); FetchOptions options = FetchOptions.Builder.doNotFollowRedirects().disallowTruncate(); HTTPRequest request = new HTTPRequest(url, HTTPMethod.GET, options); URLFetchService service = URLFetchServiceFactory.getURLFetchService(); HTTPResponse response = service.fetch(request); // ... process response.content ... } catch (ResponseTooLargeException e) { // ... } catch (MalformedURLException e) { // ... } catch (IOException e) { // ... } |
||||||||
© Lynne Grewe |