Examples of URLFetchService


Examples of com.google.appengine.api.urlfetch.URLFetchService

            FetchOptions options = FetchOptions.Builder
                .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

Examples of com.google.appengine.api.urlfetch.URLFetchService

    public static void Init(){
        Log.info("[done]");
    }
    static void Enter(String ns){
        URLFetchService ufs = UFS.get();
        if (null == ufs){
            ufs = URLFetchServiceFactory.getURLFetchService();
            UFS.set(ufs);
        }
        /*
 
View Full Code Here

Examples of com.google.appengine.api.urlfetch.URLFetchService

            FetchOptions options = FetchOptions.Builder
                .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

Examples of com.google.appengine.api.urlfetch.URLFetchService

     * @throws Exception
     *
     */
    @Test
    public void urlFetch() throws Exception {
        URLFetchService service = URLFetchServiceFactory.getURLFetchService();
        HTTPRequest httpRequest = new HTTPRequest(new URL("http://hoge"));
        String queryString = "aaa=111";
        httpRequest.setPayload(queryString.getBytes("utf-8"));
        tester.setUrlFetchHandler(new URLFetchHandler() {

            public int getStatusCode(URLFetchRequest request)
                    throws IOException {
                return 200;
            }

            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

Examples of com.google.appengine.api.urlfetch.URLFetchService

     * @throws Exception
     *
     */
    @Test
    public void urlFetchAsync() throws Exception {
        URLFetchService service = URLFetchServiceFactory.getURLFetchService();
        HTTPRequest httpRequest = new HTTPRequest(new URL("http://hoge"));
        String queryString = "aaa=111";
        httpRequest.setPayload(queryString.getBytes("utf-8"));
        tester.setUrlFetchHandler(new URLFetchHandler() {

            public int getStatusCode(URLFetchRequest request)
                    throws IOException {
                return 200;
            }

            public byte[] getContent(URLFetchRequest request)
                    throws IOException {
                return "hello".getBytes();
            }
        });
        Future<HTTPResponse> future = service.fetchAsync(httpRequest);
        HTTPResponse httpResponse = future.get();
        assertThat(httpResponse.getResponseCode(), is(200));
        assertThat(new String(httpResponse.getContent()), is("hello"));
    }
View Full Code Here

Examples of com.google.appengine.api.urlfetch.URLFetchService

  /**
   * @param url the url to set
   */
  public void setUrl(String url) {
    URLFetchService fetchService = URLFetchServiceFactory.getURLFetchService();
    FileService fileService = FileServiceFactory.getFileService();
    ImagesService imagesService = ImagesServiceFactory.getImagesService();

    HTTPResponse fetchResponse;
    try {
      fetchResponse = fetchService.fetch(new URL(url));
      Image originalImage = ImagesServiceFactory.makeImage(fetchResponse.getContent());

      AppEngineFile file = fileService.createNewBlobFile("image/" + originalImage.getFormat());
      FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
      ByteBuffer buffer = ByteBuffer.wrap(originalImage.getImageData());
View Full Code Here

Examples of com.google.appengine.api.urlfetch.URLFetchService

        boolean bridgeEndpoint = getAndRemoveParameter(parameters, "bridgeEndpoint", Boolean.class, true);
        OutboundBinding outboundBinding = resolveAndRemoveReferenceParameter(
                parameters, "outboundBindingRef", OutboundBinding.class, new GHttpBinding());
        InboundBinding inboundBinding = resolveAndRemoveReferenceParameter(
                parameters, "inboundBindingRef", InboundBinding.class, new GHttpBinding());
        URLFetchService service = resolveAndRemoveReferenceParameter(
                parameters, "urlFetchServiceRef", URLFetchService.class, URLFetchServiceFactory.getURLFetchService());
        GHttpEndpoint endpoint = (GHttpEndpoint)super.createEndpoint(uri, remaining, parameters);
        endpoint.setThrowExceptionOnFailure(throwException);
        endpoint.setBridgeEndpoint(bridgeEndpoint);
        endpoint.setOutboundBinding(outboundBinding);
View Full Code Here

Examples of com.google.appengine.api.urlfetch.URLFetchService

            apache_response.setEntity(new ByteArrayEntity(data));
        }
    }

    public HttpResponse receiveResponseHeader() {
        URLFetchService ufs = URLFetchServiceFactory.getURLFetchService();
        try {
            _appengine_hresponse = ufs.fetch(_appengine_hrequest);
        } catch (java.io.IOException e) {
            throw new RuntimeException(e);
        }

        org.apache.http.HttpResponse apache_response =
View Full Code Here

Examples of com.google.appengine.api.urlfetch.URLFetchService

          + "&" + URLEncoder.encode(params,"UTF-8");
    String sig = generateSignature(params,oauth_token_secret);
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request = new HTTPRequest(url,HTTPMethod.GET);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
    return response;
  }
View Full Code Here

Examples of com.google.appengine.api.urlfetch.URLFetchService

    else
    {
      request = new HTTPRequest(new URL(url.toString() + "?page=" + pageID),HTTPMethod.GET);
    }
    request.addHeader(new HTTPHeader("Authorization",authorization));
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
    return response;
  }
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.