Package com.google.api.client.http

Examples of com.google.api.client.http.HttpTransport


    // generate the signature
    params.computeSignature(requestMethod, url);

    // make the request
    HttpTransport transport = new NetHttpTransport();
    HttpRequestFactory f = null;
    if (useOAuth) {
      f = transport.createRequestFactory(params);
    } else {
      f = transport.createRequestFactory();
    }
    HttpRequest request = null;
    if ("POST".equals(requestMethod))
      if (postData == null)
        request = f.buildPostRequest(url, null);
View Full Code Here


    try {
      // generate the signature
      params.computeSignature(requestMethod, url);

      // make the request
      HttpTransport transport = new NetHttpTransport();
      HttpRequestFactory f = transport.createRequestFactory(params);
      HttpRequest request = f.buildGetRequest(url);

      HttpHeaders headers = new HttpHeaders();
      headers.set("X-Factual-Lib", DRIVER_HEADER_TAG);
      request.setHeaders(headers);
View Full Code Here

    Credential credential = options.getCredential();
    if (credential == null) {
      logger.warning("Not using any credentials");
      return new NetHttpTransport().createRequestFactory();
    }
    HttpTransport transport = credential.getTransport();
    return transport.createRequestFactory(credential);
  }
View Full Code Here

    private HttpResponse getResponse(GenericUrl uri) throws GeoIp2Exception,
            IOException {
        // We only use a instance variable for HttpTransport when unit testing
        // as
        // HttpTransport is not thread safe.
        HttpTransport transport = this.testTransport == null ? new NetHttpTransport()
                : this.testTransport;
        HttpRequestFactory requestFactory = transport.createRequestFactory();
        HttpRequest request;
        try {
            request = requestFactory.buildGetRequest(uri);
        } catch (IOException e) {
            throw new GeoIp2Exception("Error building request", e);
View Full Code Here

public class HostTest {

    @Test
    public void insights() throws IOException, GeoIp2Exception {
        HttpTransport transport = new TestTransport();
        WebServiceClient client = new WebServiceClient.Builder(42,
                "abcdef123456").host("blah.com").testTransport(transport)
                .build();

        InsightsResponse insights = client.insights(InetAddress
View Full Code Here

public class CountryTest {
    private CountryResponse country;

    @Before
    public void setUp() throws IOException, GeoIp2Exception {
        HttpTransport transport = new TestTransport();
        WebServiceClient client = new WebServiceClient.Builder(42,
                "abcdef123456").testTransport(transport).build();

        this.country = client.country(InetAddress.getByName("1.1.1.3"));
    }
View Full Code Here

public class InsightsTest {
    private InsightsResponse insights;

    @Before
    public void createClient() throws IOException, GeoIp2Exception {
        HttpTransport transport = new TestTransport();

        WebServiceClient client = new WebServiceClient.Builder(42, "012345689")
                .testTransport(transport).build();

        this.insights = client.insights(InetAddress.getByName("1.1.1.1"));
View Full Code Here

public class MeTest {
    private WebServiceClient client;

    @Before
    public void createClient() {
        HttpTransport transport = new TestTransport();

        this.client = new WebServiceClient.Builder(42, "abcdef123456")
                .testTransport(transport).build();

    }
View Full Code Here

    private static final List<String> SCOPES = Arrays.asList(ComputeScopes.COMPUTE, StorageScopes.DEVSTORAGE_FULL_CONTROL);

    public Compute buildCompute(GccCredential gccCredential, String appName) {
        MDCBuilder.buildMdcContext(gccCredential);
        try {
            HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
            BufferedReader br = new BufferedReader(new StringReader(gccCredential.getServiceAccountPrivateKey()));
            Security.addProvider(new BouncyCastleProvider());
            KeyPair kp = (KeyPair) new PEMReader(br).readObject();
            GoogleCredential credential = new GoogleCredential.Builder().setTransport(httpTransport)
                    .setJsonFactory(JSON_FACTORY)
View Full Code Here

    }

    public Storage buildStorage(GccCredential gccCredential, Stack stack) {
        MDCBuilder.buildMdcContext(stack);
        try {
            HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
            BufferedReader br = new BufferedReader(new StringReader(gccCredential.getServiceAccountPrivateKey()));
            Security.addProvider(new BouncyCastleProvider());
            KeyPair kp = (KeyPair) new PEMReader(br).readObject();
            GoogleCredential credential = new GoogleCredential.Builder().setTransport(httpTransport)
                    .setJsonFactory(JSON_FACTORY)
View Full Code Here

TOP

Related Classes of com.google.api.client.http.HttpTransport

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.