Package com.google.api.client.http

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


      final ResponseHandler<?> handler_) throws ServiceCallException {

    final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();

    try {
      HttpRequestFactory requestFactory = HTTP_TRANSPORT
          .createRequestFactory(new HttpRequestInitializer() {
            @Override
            public void initialize(HttpRequest request) {
            }
          });
      GenericUrl url = new GenericUrl(_url);

      HttpContent hc = new AbstractHttpContent("text/json") {
        String content = serialize(jsonServiceRequest_);
        @Override
        public void writeTo(OutputStream out_) throws IOException {
          String service = _url +jsonServiceRequest_.getService();
          if (maxPayloadLengthToLog < 0 || content.length() <= maxPayloadLengthToLog) {
            logger.info("calling service {} with payload {}", service, content);
          } else {
            logger.info("calling service {} with payload of {} chars (full payload in debug)", service, Integer.valueOf(content.length()));
            logger.debug("payload {}", content);
          }
          out_.write(content.getBytes());
        }
      };

      HttpRequest request = requestFactory.buildPostRequest(url, hc);
      HttpResponse resp = request.execute();
      InputStream is = resp.getContent();
      JsonStreamHandler<?> jsh = new JsonStreamHandler(is, handler_);

    } catch (IOException e) {
View Full Code Here

TOP

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

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.