Package com.google.api.client.http

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


      }
      T parsed = getParsedDataClass(
          requestInfo.dataClass, response, requestInfo, responseHeaders.getContentType());
      callback.onSuccess(parsed, responseHeaders);
    } else {
      HttpContent content = requestInfo.request.getContent();
      boolean retrySupported = retryAllowed && (content == null || content.retrySupported());
      boolean errorHandled = false;
      boolean redirectRequest = false;
      if (unsuccessfulResponseHandler != null) {
        errorHandled = unsuccessfulResponseHandler.handleResponse(
            requestInfo.request, response, retrySupported);
View Full Code Here


      // Write the batch headers.
      HttpHeaders.serializeHeadersForMultipartRequests(request.getHeaders(), null, null, writer);

      // Write the data to the body.
      HttpContent data = request.getContent();
      if (data != null) {
        String type = data.getType();
        if (type != null) {
          writeHeader(writer, "Content-Type", type);
        }
        long length = data.getLength();
        if (length != -1) {
          writeHeader(writer, "Content-Length", length);
        }
        writer.write(CR_LF);
        writer.flush();
        data.writeTo(out);
      }
      writer.write(CR_LF);
    }

    // Write the end of the batch separator.
View Full Code Here

    Preconditions.checkArgument(uploadState == UploadState.NOT_STARTED);

    if (directUploadEnabled) {
      updateStateAndNotifyListener(UploadState.MEDIA_IN_PROGRESS);

      HttpContent content = mediaContent;
      if (metadata != null) {
        content = new MultipartRelatedContent(metadata, mediaContent);
        initiationRequestUrl.put("uploadType", "multipart");
      } else {
        initiationRequestUrl.put("uploadType", "media");
View Full Code Here

   */
  private HttpResponse executeUploadInitiation(GenericUrl initiationRequestUrl) throws IOException {
    updateStateAndNotifyListener(UploadState.INITIATION_STARTED);

    initiationRequestUrl.put("uploadType", "resumable");
    HttpContent content = metadata == null ? new EmptyContent() : metadata;
    HttpRequest request =
        requestFactory.buildRequest(initiationMethod, initiationRequestUrl, content);
    addMethodOverride(request);
    initiationHeaders.setUploadContentType(mediaContent.getType());
    initiationHeaders.setUploadContentLength(getMediaContentLength());
View Full Code Here

  }

  public void testExecute_checkWriteToNoHeaders() throws Exception {
    MockHttpTransport transport = new MockHttpTransport();
    HttpRequest request1 = transport.createRequestFactory()
        .buildPostRequest(HttpTesting.SIMPLE_GENERIC_URL, new HttpContent() {

          @Override
          public long getLength() {
            return -1;
          }
View Full Code Here

        return;
      }
      T parsed = getParsedDataClass(requestInfo.dataClass, response, requestInfo);
      callback.onSuccess(parsed, responseHeaders);
    } else {
      HttpContent content = requestInfo.request.getContent();
      boolean retrySupported = retryAllowed && (content == null || content.retrySupported());
      boolean errorHandled = false;
      boolean redirectRequest = false;
      if (unsuccessfulResponseHandler != null) {
        errorHandled = unsuccessfulResponseHandler.handleResponse(
            requestInfo.request, response, retrySupported);
View Full Code Here

    HTTPRequestInfo(HttpRequest req) {
      method = req.getRequestMethod();
      url = req.getUrl().toURL();
      long myLength;
      HttpContent content = req.getContent();
      try {
        myLength = content == null ? -1 : content.getLength();
      } catch (IOException e) {
        myLength = -1;
      }
      length = myLength;
      h1 = req.getHeaders();
View Full Code Here

  }

  @Override
  public AppEngineClient.Response post(String path, String mimeType, byte[] body)
      throws IOException {
    HttpContent content = new ByteArrayHttpContent(mimeType, body);
    HttpRequest request = requestFactory.buildPostRequest(resolveUrl(path), content);
    addBaseHeaders(request);
    request.setFollowRedirects(false);
    return toResponse(request.execute());
  }
View Full Code Here

   * @return HTTP response
   */
  private HttpResponse directUpload(GenericUrl initiationRequestUrl) throws IOException {
    updateStateAndNotifyListener(UploadState.MEDIA_IN_PROGRESS);

    HttpContent content = mediaContent;
    if (metadata != null) {
      content = new MultipartContent().setContentParts(Arrays.asList(metadata, mediaContent));
      initiationRequestUrl.put("uploadType", "multipart");
    } else {
      initiationRequestUrl.put("uploadType", "media");
View Full Code Here

   */
  private HttpResponse executeUploadInitiation(GenericUrl initiationRequestUrl) throws IOException {
    updateStateAndNotifyListener(UploadState.INITIATION_STARTED);

    initiationRequestUrl.put("uploadType", "resumable");
    HttpContent content = metadata == null ? new EmptyContent() : metadata;
    HttpRequest request =
        requestFactory.buildRequest(initiationRequestMethod, initiationRequestUrl, content);
    initiationHeaders.set(CONTENT_TYPE_HEADER, mediaContent.getType());
    if (isMediaLengthKnown()) {
      initiationHeaders.set(CONTENT_LENGTH_HEADER, getMediaContentLength());
View Full Code Here

TOP

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

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.