Package com.google.appengine.api.urlfetch

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


  private void addOptionsHeaders(HTTPRequest req, GcsFileOptions options) {
    if (options == null) {
      return;
    }
    if (options.getMimeType() != null) {
      req.setHeader(new HTTPHeader(CONTENT_TYPE, options.getMimeType()));
    }
    if (options.getAcl() != null) {
      req.setHeader(new HTTPHeader(ACL, options.getAcl()));
    }
    if (options.getCacheControl() != null) {
      req.setHeader(new HTTPHeader(CACHE_CONTROL, options.getCacheControl()));
    }
    if (options.getContentDisposition() != null) {
      req.setHeader(new HTTPHeader(CONTENT_DISPOSITION, options.getContentDisposition()));
    }
    if (options.getContentEncoding() != null) {
      req.setHeader(new HTTPHeader(CONTENT_ENCODING, options.getContentEncoding()));
    }
    for (Entry<String, String> entry : options.getUserMetadata().entrySet()) {
      req.setHeader(new HTTPHeader(X_GOOG_META + entry.getKey(), entry.getValue()));
    }
  }
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);
View Full Code Here

    }
    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

    Preconditions.checkArgument(n > 0, "%s: dst full: %s", this, dst);
    final int want = Math.min(READ_LIMIT_BYTES, n);

    final HTTPRequest req = makeRequest(filename, null, GET, timeoutMillis, headers);
    req.setHeader(
        new HTTPHeader(RANGE, "bytes=" + startOffsetBytes + "-" + (startOffsetBytes + want - 1)));
    final HTTPRequestInfo info = new HTTPRequestInfo(req);
    return new FutureWrapper<HTTPResponse, GcsFileMetadata>(urlfetch.fetchAsync(req)) {
      @Override
      protected GcsFileMetadata wrap(HTTPResponse resp) throws IOException {
        long totalLength;
View Full Code Here

      xmlContent.append(escaper.escape(srcFileName));
      xmlContent.append("</Name></Component>");
    }
    xmlContent.append("</ComposeRequest>");
    byte[] payload = xmlContent.toString().getBytes(UTF_8);
    req.setHeader(new HTTPHeader(CONTENT_LENGTH, String.valueOf(payload.length)));
    req.setPayload(payload);
    HTTPResponse resp;
    try {
      resp = urlfetch.fetch(req);
    } catch (IOException 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) {
View Full Code Here

      HttpRequestOptions requestOptions) {

    String contentType = requestOptions.getContentType();

    if (contentType != null) {
      httpRequest.addHeader(new HTTPHeader("Content-Type", contentType));
    }

    Map<String, String> headers = getRequestHeaders(requestOptions);

    if (headers != null) {
      for (Map.Entry<String, String> header : headers.entrySet()) {
        httpRequest.addHeader(new HTTPHeader(header.getKey(), header.getValue()));
      }
    }
  }
View Full Code Here

    protected void writeRequestHeaders(GHttpEndpoint endpoint, Exchange exchange, HTTPRequest request) {
        HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
        for (String headerName : exchange.getIn().getHeaders().keySet()) {
            String headerValue = exchange.getIn().getHeader(headerName, String.class);
            if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
                request.addHeader(new HTTPHeader(headerName, headerValue));
            }
        }
    }
View Full Code Here

  }

  private void addCookies(HTTPRequest req) {
    for (Cookie cookie : getAuthCookies()) {
      req.addHeader(
          new HTTPHeader("Cookie", String.format("%s=%s", cookie.getName(), cookie.getValue())));
    }
  }
View Full Code Here

  @Override
  public Response get(String path) throws IOException {
    HTTPRequest req = new HTTPRequest(new URL(makeUrl(path)), HTTPMethod.GET);
    req.getFetchOptions().doNotFollowRedirects();
    for (String[] headerPair : getHeadersForGet()) {
      req.addHeader(new HTTPHeader(headerPair[0], headerPair[1]));
    }
    addCookies(req);
    HTTPResponse resp = urlFetch.fetch(req);
    return createResponse(resp);
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.urlfetch.HTTPHeader

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.