Package com.google.appengine.api.urlfetch

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


    return request;
  }

  @Override
  public HTTPResponse fetch(HTTPRequest req) throws IOException, RetryHelperException {
    HTTPRequest authorizedRequest = createAuthorizeRequest(req);
    return urlFetch.fetch(authorizedRequest);
  }
View Full Code Here


    return urlFetch.fetch(authorizedRequest);
  }

  @Override
  public Future<HTTPResponse> fetchAsync(HTTPRequest req) {
    HTTPRequest authorizedRequest;
    try {
      authorizedRequest = createAuthorizeRequest(req);
    } catch (RetryHelperException e) {
      return Futures.immediateFailedCheckedFuture(e);
    }
View Full Code Here

  }

  @Override
  public void copyObject(GcsFilename source, GcsFilename dest, long timeoutMillis)
      throws IOException {
    HTTPRequest req = makeRequest(dest, null, PUT, timeoutMillis, headers);
    req.setHeader(new HTTPHeader(X_GOOG_COPY_SOURCE, makePath(source)));
    req.setHeader(ZERO_CONTENT_LENGTH);
    HTTPResponse resp;
    try {
      resp = urlfetch.fetch(req);
    } catch (IOException e) {
      throw createIOException(new HTTPRequestInfo(req), e);
View Full Code Here

      queryStrings.put(MARKER, marker);
    }
    if (maxResults >= 0) {
      queryStrings.put(MAX_KEYS, String.valueOf(maxResults));
    }
    HTTPRequest req = makeRequest(filename, queryStrings, GET, timeoutMillis, headers);
    req.setHeader(ZERO_CONTENT_LENGTH);
    HTTPResponse resp;
    try {
      resp = urlfetch.fetch(req);
    } catch (IOException e) {
      throw createIOException(new HTTPRequestInfo(req), e);
View Full Code Here

  static String getSingleHeader(HTTPResponse resp, String headerName) {
    return Iterables.getOnlyElement(getHeaders(resp, headerName)).getValue();
  }

  static HTTPRequest copyRequest(HTTPRequest in) {
    HTTPRequest out = new HTTPRequest(in.getURL(), in.getMethod(), in.getFetchOptions());
    for (HTTPHeader h : in.getHeaders()) {
      out.addHeader(h);
    }
    out.setPayload(in.getPayload());
    return out;
  }
View Full Code Here

    }
  }

  private static HTTPRequest makeRequest(GcsFilename filename, Map<String, String> queryStrings,
      HTTPMethod method, long timeoutMillis, Set<HTTPHeader> headers) {
    HTTPRequest request = new HTTPRequest(makeUrl(filename, queryStrings), method,
        FetchOptions.Builder.disallowTruncate()
            .doNotFollowRedirects()
            .validateCertificate()
            .setDeadline(timeoutMillis / 1000.0));
    for (HTTPHeader header : headers) {
      request.addHeader(header);
    }
    request.addHeader(USER_AGENT);
    return request;
  }
View Full Code Here

  }

  @Override
  public RawGcsCreationToken beginObjectCreation(
      GcsFilename filename, GcsFileOptions options, long timeoutMillis) throws IOException {
    HTTPRequest req = makeRequest(filename, null, POST, timeoutMillis, headers);
    req.setHeader(RESUMABLE_HEADER);
    addOptionsHeaders(req, options);
    HTTPResponse resp;
    try {
      resp = urlfetch.fetch(req);
    } catch (IOException e) {
View Full Code Here

  }

  @Override
  public void putObject(GcsFilename filename, GcsFileOptions options, ByteBuffer content,
      long timeoutMillis) throws IOException {
    HTTPRequest req = makeRequest(filename, null, PUT, timeoutMillis, headers);
    req.setHeader(new HTTPHeader(CONTENT_LENGTH, String.valueOf(content.remaining())));
    req.setPayload(peekBytes(content));
    addOptionsHeaders(req, options);
    HTTPResponse resp;
    try {
      resp = urlfetch.fetch(req);
    } catch (IOException e) {
View Full Code Here

          + " bytes at offset " + String.format("0x%x", offset)
          + "; isFinalChunk: " + isFinalChunk + ")");
    }
    long limit = offset + length;
    Map<String, String> queryStrings = Collections.singletonMap(UPLOAD_ID, token.uploadId);
    final HTTPRequest req = makeRequest(token.filename, queryStrings, PUT, timeoutMillis, headers);
    req.setHeader(
        new HTTPHeader(CONTENT_RANGE,
            "bytes " + (length == 0 ? "*" : offset + "-" + (limit - 1))
            + (isFinalChunk ? "/" + limit : "/*")));
    req.setPayload(peekBytes(chunk));
    return req;
  }
View Full Code Here

   * will be closed.
   */
  private RawGcsCreationToken put(final GcsRestCreationToken token, ByteBuffer chunk,
      final boolean isFinalChunk, long timeoutMillis) throws IOException {
    final int length = chunk.remaining();
    HTTPRequest req = createPutRequest(token, chunk, isFinalChunk, timeoutMillis, length);
    HTTPRequestInfo info = new HTTPRequestInfo(req);
    HTTPResponse response;
    try {
      response = urlfetch.fetch(req);
    } catch (IOException e) {
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.