Package com.google.appengine.api.urlfetch

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


    }
   
    @Test(expected = GHttpException.class)
    public void testFailureException() throws Exception {
        GHttpEndpoint endpoint = createEndpoint(getBaseUri("ghttp") + "/test");
        HTTPRequest request = new HTTPRequest(endpoint.getEndpointUrl());
        request.addHeader(new HTTPHeader("code", "500"));
        HTTPResponse response = service.fetch(request);
        binding.readResponse(endpoint, exchange, response);
    }
View Full Code Here


    }
   
    @Test
    public void testFailureNoException() throws Exception {
        GHttpEndpoint endpoint = createEndpoint(getBaseUri("ghttp") + "/test?throwExceptionOnFailure=false");
        HTTPRequest request = new HTTPRequest(endpoint.getEndpointUrl());
        request.addHeader(new HTTPHeader("code", "500"));
        HTTPResponse response = service.fetch(request);
        binding.readResponse(endpoint, exchange, response);
        assertEquals(500, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
    }
View Full Code Here

    public static HTTPRequest createRequest() throws Exception {
        return createRequest("http://localhost:8080");
    }
   
    public static HTTPRequest createRequest(String url) throws Exception {
        return new HTTPRequest(new URL(url));
    }
View Full Code Here

        } catch (java.net.MalformedURLException e) {
            throw new RuntimeException(e);
        }

        HTTPMethod method = HTTPMethod.valueOf(apache_request.getRequestLine().getMethod());
        _appengine_hrequest = new HTTPRequest(request_url, method, allowTruncate()
                                              .doNotFollowRedirects());

        Header[] apache_headers = apache_request.getAllHeaders();
        for (int i = 0; i < apache_headers.length; i++) {
            Header h = apache_headers[i];
View Full Code Here

    String params = generateParams(timestamp,nonce);
    params = "GET&" + URLEncoder.encode(url.toString(),"UTF-8")
          + "&" + 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

   
    params = "GET&" + URLEncoder.encode(url.toString(),"UTF-8")
          + "&" + URLEncoder.encode(params,"UTF-8");
    String sig = generateSignature(params,oauth_token_secret);
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request;
    if(pageID == null)
    {
      request = new HTTPRequest(url,HTTPMethod.GET);
    }
    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

    params = "POST&" + URLEncoder.encode(url.toString(),"UTF-8")
          + "&" + URLEncoder.encode(params,"UTF-8");
    String sig = generateSignature(params,oauth_token_secret);
    System.out.println(params);
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request = new HTTPRequest(url,HTTPMethod.POST);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    request.addHeader(new HTTPHeader("Content-Type","application/x-www-form-urlencoded"));

    String strPayload = "id=" + id;
    request.setPayload(strPayload.getBytes());
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
   
    return response;
  }
View Full Code Here

    params = "POST&" + URLEncoder.encode(url.toString(),"UTF-8")
          + "&" + URLEncoder.encode(params,"UTF-8");
    String sig = generateSignature(params,oauth_token_secret);
   
    String authorization = generateAuthString(timestamp, nonce, sig);
    HTTPRequest request = new HTTPRequest(url,HTTPMethod.POST);
    request.addHeader(new HTTPHeader("Authorization",authorization));
    request.addHeader(new HTTPHeader("Content-Type","application/x-www-form-urlencoded"));
   
    String strPayload = "id=" + id;
    request.setPayload(strPayload.getBytes());
    URLFetchService service = URLFetchServiceFactory.getURLFetchService();
    HTTPResponse response = service.fetch(request);
   
    return response;
  }
View Full Code Here

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

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

TOP

Related Classes of com.google.appengine.api.urlfetch.HTTPRequest

Copyright © 2018 www.massapicom. 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.