Package com.google.appengine.api.urlfetch

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


        fetchUrl("http://i.do.not.exist/", 503);
    }

    protected String fetchUrl(String url, int expectedResponse) throws IOException {
        URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService();
        HTTPResponse httpResponse = urlFetchService.fetch(new URL(url));
        assertEquals(url, expectedResponse, httpResponse.getResponseCode());
        return new String(httpResponse.getContent());
    }

    // N.B. Tests below this point bypass FastNet
View Full Code Here


        FetchOptions fetchOptions = FetchOptions.Builder.withDefaults()
            .doNotFollowRedirects()
            .setDeadline(10.0);
        HTTPRequest httpRequest = new HTTPRequest(selfURL, HTTPMethod.GET, fetchOptions);
        URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService();
        HTTPResponse httpResponse = urlFetchService.fetch(httpRequest);
        fail("expected exception, got " + httpResponse.getResponseCode());
    }

//  @Test
//  public void timeoutRaiseSocketTimeoutException() throws Exception {
View Full Code Here

    }

    protected void testOptions(URL url, HTTPMethod method, FetchOptions options, ResponseHandler handler) throws Exception {
        HTTPRequest request = new HTTPRequest(url, method, options);
        URLFetchService service = URLFetchServiceFactory.getURLFetchService();
        HTTPResponse response = service.fetch(request);
        handler.handle(response);
    }

    protected static interface ResponseHandler {
        void handle(HTTPResponse response) throws Exception;
View Full Code Here

        FetchOptions options = FetchOptions.Builder.followRedirects();

        HTTPRequest request = new HTTPRequest(redirectUrl, HTTPMethod.GET, options);
        URLFetchService service = URLFetchServiceFactory.getURLFetchService();
        HTTPResponse response = service.fetch(request);
        String destinationUrl = response.getFinalUrl().toString();
        assertTrue("Did not get redirected.", destinationUrl.startsWith(expectedDestinationURLPrefix));
    }

    @Test
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.