Package com.google.appengine.api.urlfetch

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


    private Media getPhotoMedia(String imageUrl) throws MalformedURLException, IOException {

        URLFetchService fetchService =
                URLFetchServiceFactory.getURLFetchService();
        HTTPResponse fetchResponse = fetchService.fetch(new URL(imageUrl));

        InputStream inputStream = new ByteArrayInputStream(fetchResponse.getContent());

        return new Media("photo by plucial", inputStream);
View Full Code Here


            request.setPayload((byte[]) options.get("payload"));
        }

        // do an async call, if the async: true option is present
        if (options.containsKey("async") && DefaultGroovyMethods.asBoolean(options.get("async"))) return urlFetch.fetchAsync(request);
        return urlFetch.fetch(request);
    }

    /**
     * Use the URLFetch Service to do a GET on the URL.
     *
 
View Full Code Here

  java.net.URL url = new java.net.URL(strUrl);

  HTTPRequest request = new HTTPRequest(url, HTTPMethod.GET, FetchOptions.Builder.withDeadline(TIMEOUT_SECONDS));

  HTTPResponse response = ufs.fetch(request);

  byte[] content = response.getContent();

  return new String(content, Constants.HTTP_ENCODEING);
  }
View Full Code Here

  request.setPayload(payload.getBytes());
 
  log.info("doPost url :" + strUrl);

  HTTPResponse response = ufs.fetch(request);

  byte[] content = response.getContent();

  return new String(content, Constants.HTTP_ENCODEING);
  }
View Full Code Here

  // multipart
  for (Map.Entry<String, String> fileUrlMap : fileUrlMaps.entrySet()) {
    log.info("fetch binary file: " + fileUrlMap.getValue());
    HTTPRequest donwloadFilerequest = new HTTPRequest(new java.net.URL(fileUrlMap.getValue()), HTTPMethod.GET, FetchOptions.Builder.withDeadline(TIMEOUT_SECONDS));
    HTTPResponse donwloadFileResponse = ufs.fetch(donwloadFilerequest);

    byte[] binaryContent = donwloadFileResponse.getContent();

    String contentType = null;
    for (HTTPHeader header : donwloadFileResponse.getHeaders()) {
View Full Code Here

  write(baos, "--" + boundary + "--\r\n");

  request.setPayload(baos.toByteArray());

  HTTPResponse response = ufs.fetch(request);

  byte[] content = response.getContent();

  return new String(content, Constants.HTTP_ENCODEING);
  }
View Full Code Here

    @Test
    public void testBasicOps() throws Exception {
        URLFetchService service = URLFetchServiceFactory.getURLFetchService();

        URL adminConsole = findAvailableUrl(URLS);
        HTTPResponse response = service.fetch(adminConsole);
        printResponse(response);

        URL jbossOrg = new URL("http://www.jboss.org");
        if (available(jbossOrg)) {
            response = service.fetch(jbossOrg);
View Full Code Here

        HTTPResponse response = service.fetch(adminConsole);
        printResponse(response);

        URL jbossOrg = new URL("http://www.jboss.org");
        if (available(jbossOrg)) {
            response = service.fetch(jbossOrg);
            printResponse(response);
        }
    }

    @Test
View Full Code Here

        HTTPRequest req = new HTTPRequest(url, HTTPMethod.POST);
        req.setHeader(new HTTPHeader("Content-Type", "application/octet-stream"));
        req.setPayload("Tralala".getBytes(UTF_8));

        HTTPResponse response = service.fetch(req);
        String content = new String(response.getContent());
        Assert.assertEquals("Hopsasa", content);
    }

    @Test
View Full Code Here

        HTTPRequest req = new HTTPRequest(url, HTTPMethod.POST);
        req.setHeader(new HTTPHeader("Content-Type", "application/octet-stream"));
        req.setPayload("Headers!".getBytes(UTF_8));

        HTTPResponse response = service.fetch(req);

        boolean found = false;
        List<HTTPHeader> headers = response.getHeadersUncombined();
        for (HTTPHeader h : headers) {
            if (h.getName().equals("ABC")) {
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.