Examples of HTTPRequestInfo


Examples of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo

      exception = ex;
    }
    String expected = "Request: DELETE " + Storage.DEFAULT_BASE_URL + "b/b/o/o\n"
        + "k1: v1\nk2: v2\n\nno content\n\nResponse: 400 with 0 bytes of content\n";
    String result =
        URLFetchUtils.describeRequestAndResponse(new HTTPRequestInfo(request), exception);
    assertTrue(expected + "\nis not a prefix of:\n" + result, result.startsWith(expected));
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo

    when(response.getResponseCode()).thenReturn(500);
    when(response.getContent()).thenReturn("bla".getBytes());
    String expected = "Request: GET http://ping/pong\nk1: v1\nk2: v2\n\n"
        + "5 bytes of content\n\nResponse: 500 with 3 bytes of content\nk3: v3\nbla\n";
    String result =
        URLFetchUtils.describeRequestAndResponse(new HTTPRequestInfo(request), response);
    assertEquals(expected, result);
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo

    addOptionsHeaders(req, options);
    HTTPResponse resp;
    try {
      resp = urlfetch.fetch(req);
    } catch (IOException e) {
      throw createIOException(new HTTPRequestInfo(req), e);
    }
    if (resp.getResponseCode() == 201) {
      String location = URLFetchUtils.getSingleHeader(resp, LOCATION);
      String queryString = new URL(location).getQuery();
      Preconditions.checkState(
          queryString != null, LOCATION + " header," + location + ", witout a query string");
      Map<String, String> params = Splitter.on('&').withKeyValueSeparator('=').split(queryString);
      Preconditions.checkState(params.containsKey(UPLOAD_ID),
          LOCATION + " header," + location + ", has a query string without " + UPLOAD_ID);
      return new GcsRestCreationToken(filename, params.get(UPLOAD_ID), 0);
    } else {
      throw HttpErrorHandler.error(new HTTPRequestInfo(req), resp);
    }
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo

    addOptionsHeaders(req, options);
    HTTPResponse resp;
    try {
      resp = urlfetch.fetch(req);
    } catch (IOException e) {
      throw createIOException(new HTTPRequestInfo(req), e);
    }
    if (resp.getResponseCode() != 200) {
      throw HttpErrorHandler.error(new HTTPRequestInfo(req), resp);
    }
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo

   */
  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) {
      throw createIOException(info, e);
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo

   */
  private Future<RawGcsCreationToken> putAsync(final GcsRestCreationToken token,
      ByteBuffer chunk, final boolean isFinalChunk, long timeoutMillis) {
    final int length = chunk.remaining();
    HTTPRequest request = createPutRequest(token, chunk, isFinalChunk, timeoutMillis, length);
    final HTTPRequestInfo info = new HTTPRequestInfo(request);
    return new FutureWrapper<HTTPResponse, RawGcsCreationToken>(urlfetch.fetchAsync(request)) {
      @Override
      protected Throwable convertException(Throwable e) {
        return OauthRawGcsService.convertException(info, e);
      }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo

    HTTPRequest req = makeRequest(filename, null, DELETE, timeoutMillis, headers);
    HTTPResponse resp;
    try {
      resp = urlfetch.fetch(req);
    } catch (IOException e) {
      throw createIOException(new HTTPRequestInfo(req), e);
    }
    switch (resp.getResponseCode()) {
      case 204:
        return true;
      case 404:
        return false;
      default:
        throw HttpErrorHandler.error(new HTTPRequestInfo(req), resp);
    }
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo

    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;
        switch (resp.getResponseCode()) {
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo

    HTTPRequest req = makeRequest(filename, null, HEAD, timeoutMillis, headers);
    HTTPResponse resp;
    try {
      resp = urlfetch.fetch(req);
    } catch (IOException e) {
      throw createIOException(new HTTPRequestInfo(req), e);
    }
    int responseCode = resp.getResponseCode();
    if (responseCode == 404) {
      return null;
    }
    if (responseCode != 200) {
      throw HttpErrorHandler.error(new HTTPRequestInfo(req), resp);
    }
    return getMetadataFromResponse(
        filename, resp, getLengthFromHeader(resp, X_GOOG_CONTENT_LENGTH));
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.oauth.URLFetchUtils.HTTPRequestInfo

    req.setPayload(payload);
    HTTPResponse resp;
    try {
      resp = urlfetch.fetch(req);
    } catch (IOException e) {
      throw createIOException(new HTTPRequestInfo(req), e);
    }
    if (resp.getResponseCode() != 200) {
      throw HttpErrorHandler.error(new HTTPRequestInfo(req), resp);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.