Package com.google.api.client.http

Examples of com.google.api.client.http.HttpHeaders$HeaderParsingFakeLevelHttpRequest


  public HttpManager() {
    requestFactory = APACHE_HTTP_TRANSPORT.createRequestFactory(new HttpRequestInitializer() {
      @Override
      public void initialize(HttpRequest hr) throws IOException {
        hr.setParser(new XmlObjectParser(DefaultConfigs.DOUBAN_XML_NAMESPACE));
        HttpHeaders header = new HttpHeaders();
        header.setUserAgent("Dongxuexidu - Douban Java SDK");
        hr.setHeaders(header);
        hr.setNumberOfRetries(3);
      }
    });
  }
View Full Code Here


    try {
      if (needToken) {
        if (!hasAccessTokenBeenSet()) {
          throw ErrorHandler.accessTokenNotSet();
        }
        HttpHeaders headers = method.getHeaders();
        headers.setAuthorization("Bearer " + this.accessToken);
      }
      HttpResponse res = method.execute();
      return res;
    } catch (HttpResponseException ex) {
      throw ErrorHandler.handleHttpResponseError(ex);
View Full Code Here

      while ((count = inputStream.read(buffer)) > 0) {
        bos.write(buffer, 0, count);
      }
      bos.close();
     
      final HttpHeaders headers = response.getHeaders();
      final String lastModified = headers.getLastModified();
      final Long size = headers.getContentLength() == null ? 0 : headers.getContentLength();
      final Date date = lastModified == null ? new Date(0) : dateFormat.get().parse(lastModified);


      return new FileInfo(size, date.getTime(), bos.toByteArray());
    } catch (Exception e) {
View Full Code Here

      request = netHttpTransport.createRequestFactory().buildGetRequest(new GenericUrl(uri));
      HttpResponse response = request.execute();
      if (response.getStatusCode() != HttpStatusCodes.STATUS_CODE_OK) {
        throw new RuntimeException("Invalid request: " + uri);
      }
      final HttpHeaders headers = response.getHeaders();
      final String lastModified = headers.getLastModified();
      final Long size = headers.getContentLength() == null ? 0 : headers.getContentLength();
      final Date date = lastModified == null ? new Date(0) : dateFormat.get().parse(lastModified);
     
      if (!overwrite && destination.exists() && destination.lastModified() >= date.getTime() && destination.length() == size) {
        logger.info("File on disk is same or newer : " + destination);
        return;
View Full Code Here

    if (readTimeout != -1)
      request.setReadTimeout(readTimeout);
    if (connectionTimeout != -1)
      request.setConnectTimeout(connectionTimeout);

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

      final String requestUrl = String.format("%s%s", STUBS_URL, "/invoice/123");
      final String content = "{\"name\": \"milk\", \"description\": \"full\", \"department\": \"savoury\"}";
      final HttpRequest request = HttpUtils.constructHttpRequest(HttpMethods.PUT, requestUrl, content);

      final HttpHeaders httpHeaders = new HttpHeaders();
      httpHeaders.setContentType(HEADER_APPLICATION_JSON);

      request.setHeaders(httpHeaders);

      final HttpResponse response = request.execute();
      final String contentTypeHeader = response.getContentType();
View Full Code Here

      final String requestUrl = String.format("%s%s", STUBS_SSL_URL, "/invoice/123");
      final String content = "{\"name\": \"milk\", \"description\": \"full\", \"department\": \"savoury\"}";
      final HttpRequest request = HttpUtils.constructHttpRequest(HttpMethods.PUT, requestUrl, content);

      final HttpHeaders httpHeaders = new HttpHeaders();
      httpHeaders.setContentType(HEADER_APPLICATION_JSON);

      request.setHeaders(httpHeaders);

      final HttpResponse response = request.execute();
      final String contentTypeHeader = response.getContentType();
View Full Code Here

      final String requestUrl = String.format("%s%s", STUBS_URL, "/invoice/123");
      final String content = "{\"wrong\": \"post\"}";
      final HttpRequest request = HttpUtils.constructHttpRequest(HttpMethods.PUT, requestUrl, content);

      final HttpHeaders httpHeaders = new HttpHeaders();
      httpHeaders.setContentType(HEADER_APPLICATION_JSON);

      request.setHeaders(httpHeaders);

      final HttpResponse response = request.execute();
      final String responseContentAsString = response.parseAsString().trim();
View Full Code Here

      final String requestUrl = String.format("%s%s", STUBS_SSL_URL, "/invoice/123");
      final String content = "{\"wrong\": \"post\"}";
      final HttpRequest request = HttpUtils.constructHttpRequest(HttpMethods.PUT, requestUrl, content);

      final HttpHeaders httpHeaders = new HttpHeaders();
      httpHeaders.setContentType(HEADER_APPLICATION_JSON);

      request.setHeaders(httpHeaders);

      final HttpResponse response = request.execute();
      final String responseContentAsString = response.parseAsString().trim();
View Full Code Here

      final String requestUrl = String.format("%s%s", STUBS_URL, "/invoice/new");
      final String content = "{\"name\": \"chocolate\", \"description\": \"full\", \"department\": \"savoury\"}";
      final HttpRequest request = HttpUtils.constructHttpRequest(HttpMethods.POST, requestUrl, content);

      final HttpHeaders httpHeaders = new HttpHeaders();
      httpHeaders.setContentType(HEADER_APPLICATION_JSON);

      request.setHeaders(httpHeaders);

      final HttpResponse response = request.execute();
      final String contentTypeHeader = response.getContentType();
View Full Code Here

TOP

Related Classes of com.google.api.client.http.HttpHeaders$HeaderParsingFakeLevelHttpRequest

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.