Package com.google.appengine.api.urlfetch

Examples of com.google.appengine.api.urlfetch.URLFetchService.fetch()


    URLFetchService ufs = URLFetchServiceFactory.getURLFetchService();
    HTTPRequest req = new HTTPRequest(url, HTTPMethod.POST);
    req.setPayload(getwork.toString().getBytes());
    req.addHeader(new HTTPHeader("Authorization", config.getAuth()));

    HTTPResponse resp = ufs.fetch(req);
    String content = new String(resp.getContent());
    if (resp.getResponseCode() != 200) {
      throw new IOException( //
          "fetchWork Error: " + resp.getResponseCode() + " "
              + content);
View Full Code Here


    URLFetchService ufs = URLFetchServiceFactory.getURLFetchService();
    HTTPRequest req = new HTTPRequest(url, HTTPMethod.POST);
    req.setPayload(getwork.toString().getBytes());
    req.addHeader(new HTTPHeader("Authorization", config.getAuth()));

    HTTPResponse resp = ufs.fetch(req);
    String content = new String(resp.getContent());
    if (resp.getResponseCode() != 200) {
      log.severe( //
      "submitWork Error: " + resp.getResponseCode() + " " + content);
      return false;
View Full Code Here

   
    //URL url = new URL(urlStr);
    URLFetchService urlFetchService =
    URLFetchServiceFactory.getURLFetchService();
    HTTPRequest httpRequest = new HTTPRequest(url);
    HTTPResponse response = urlFetchService.fetch(httpRequest);
   
   
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    conn.setReadTimeout(60000);
    conn.setConnectTimeout(60000);
View Full Code Here

  public static byte[] getFile(String URLName) {

    try {
      URL url = new URL(URLName);
      URLFetchService u = URLFetchServiceFactory.getURLFetchService();
      HTTPResponse r = u.fetch(url);

      return r.getContent();

    } catch (MalformedURLException e) {
      System.err.println("Malformed URL:" + URLName);
View Full Code Here

      }
    }
    // connect
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    try {
      HTTPResponse response = service.fetch(request);
      return new UrlFetchResponse(response);
    } catch (ResponseTooLargeException e) {
      IOException ioException = new IOException();
      ioException.initCause(e);
      throw ioException;
View Full Code Here

        //if were updating the auth
        if (null == authEntity || !authEntity.getProperty("secret").equals(updateAuth)) {
          //if there is no auth key, or the auth key doesn't match the one provided
          try {
            URLFetchService fetchService = URLFetchServiceFactory.getURLFetchService();
            HTTPResponse response = fetchService.fetch(new URL(SECURE_HOST + "/auth/?site=" + req.getHeader("Host") + "&auth=" + updateAuth));
           
            if (response.getResponseCode() == 200) {
              //if successfully received a response, save the new auth key
              String content = new String(response.getContent());
              if (content.equals(new String("OK"))) {
View Full Code Here

        if (null == authEntity || !authEntity.getProperty("secret").equals(updateAuth)) {
          //if there is no auth key, or the auth key doesn't match the one provided
          try {
            URLFetchService fetchService = URLFetchServiceFactory.getURLFetchService();
            String host = URLEncoder.encode(req.getHeader("Host"), "UTF-8");
            HTTPResponse response = fetchService.fetch(new URL(SECURE_HOST + "/auth/?site=" + host + "&auth=" + updateAuth));

            if (response.getResponseCode() == 200) {
              //if successfully received a response, save the new auth key
              String content = new String(response.getContent());
              if (content.equals(new String("OK"))) {
View Full Code Here

                .doNotFollowRedirects()
                .disallowTruncate();
            HTTPRequest request = new HTTPRequest(url, HTTPMethod.GET, options);

            URLFetchService service = URLFetchServiceFactory.getURLFetchService();
            HTTPResponse response = service.fetch(request);

            byte[] content = response.getContent();
            out.println("<p>Read PGAE blog feed (" + content.length + " characters).</p>");

        } catch (ResponseTooLargeException e) {
View Full Code Here

                .doNotFollowRedirects()
                .disallowTruncate();
            HTTPRequest request = new HTTPRequest(url, HTTPMethod.GET, options);

            URLFetchService service = URLFetchServiceFactory.getURLFetchService();
            HTTPResponse response = service.fetch(request);

            byte[] content = response.getContent();
            out.println("<p>Read PGAE blog feed (" + content.length + " characters).</p>");

        } catch (ResponseTooLargeException e) {
View Full Code Here

            public byte[] getContent(URLFetchRequest request)
                    throws IOException {
                return "hello".getBytes();
            }
        });
        HTTPResponse httpResponse = service.fetch(httpRequest);
        assertThat(httpResponse.getResponseCode(), is(200));
        assertThat(new String(httpResponse.getContent()), is("hello"));
    }

    /**
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.