Package org.apache.shindig.gadgets.http

Examples of org.apache.shindig.gadgets.http.HttpResponseBuilder.create()


  private String verifyStrip(String body) {
    HttpResponseBuilder resp = new HttpResponseBuilder()
        .setHttpStatusCode(200)
        .setHeader("Date", "Date: Fri, 09 Jan 2009 00:35:08 GMT")
        .setResponseString(body);
    String out = OAuthResponseParams.filterSecrets(resp.create().toString());
    if (out.contains("oauth_token_secret")) {
      checkStringContains("should remove secret", out, "oauth_token_secret=REMOVED");
    }
    if (out.contains("oauth_session_handle")) {
      checkStringContains("should remove handle", out, "oauth_session_handle=REMOVED");
View Full Code Here


  private HttpResponse sendErrorResponse(final Throwable t, final OAuth2Error error,
      final String contextMessage) {
    final HttpResponseBuilder responseBuilder = this.getErrorResponseBuilder(t, error,
        contextMessage);
    return responseBuilder.create();
  }

  private HttpResponse sendErrorResponse(final Throwable t, final OAuth2Error error,
      final String contextMessage, final String errorUri, final String errorDescription) {
    final HttpResponseBuilder responseBuilder = this.getErrorResponseBuilder(t, error,
View Full Code Here

  private HttpResponse sendErrorResponse(final Throwable t, final OAuth2Error error,
      final String contextMessage, final String errorUri, final String errorDescription) {
    final HttpResponseBuilder responseBuilder = this.getErrorResponseBuilder(t, error,
        contextMessage, errorUri, errorDescription);
    return responseBuilder.create();
  }

  private static boolean haveAccessToken(final OAuth2Accessor accessor) {
    OAuth2Token token = accessor.getAccessToken();
    return token != null && DominoOAuth2Request.validateAccessToken(token);
View Full Code Here

      responseParams.setSendTraceToClient(true);
      response = new HttpResponseBuilder()
          .setHttpStatusCode(HttpResponse.SC_FORBIDDEN)
          .setStrictNoCache();
      responseParams.addToResponse(response);
      return response.create();
    }

    // OK, got some data back, annotate it as necessary.
    if (response.getHttpStatusCode() >= 400) {
      responseParams.logDetailedWarning("OAuth fetch fatal error");
View Full Code Here

      responseParams.setSendTraceToClient(true);
    }

    responseParams.addToResponse(response);

    return response.create();
  }

  /**
   * Fetch data, retrying in the event that that the service provider returns an error and we think
   * we can recover by restarting the protocol flow.
View Full Code Here

      resp.setHeader(BODY_ECHO_HEADER, info.body);
    }
    if (info.rawBody != null) {
      resp.setHeader(RAW_BODY_ECHO_HEADER, new String(Base64.encodeBase64(info.rawBody)));
    }
    return resp.create();
  }
 
  private void validateMessage(OAuthAccessor accessor, MessageInfo info, boolean tokenEndpoint)
      throws OAuthException, IOException, URISyntaxException {
    info.message.validateMessage(accessor, new FakeTimeOAuthValidator());
View Full Code Here

      boolean isOversizedImage = isImageTooLarge(imageInfo);
      if (isResizeRequested && isOversizedImage) {
        HttpResponseBuilder rejectedResponseBuilder = new HttpResponseBuilder()
            .setHttpStatusCode(HttpResponse.SC_FORBIDDEN)
            .setResponseString(RESIZE_IMAGE_TOO_LARGE);
        return rejectedResponseBuilder.create();
      }

      // Don't handle animations.
      // TODO: This doesn't work as current Sanselan doesn't return accurate image counts.
      // See animated GIF detection below.
View Full Code Here

    byte[] imageBytes = outputter.toBytes(image);
    HttpResponseBuilder newResponseBuilder = new HttpResponseBuilder(response)
        .setResponse(imageBytes)
        .setHeader(CONTENT_TYPE, CONTENT_TYPE_IMAGE_PNG)
        .setHeader(CONTENT_LENGTH, String.valueOf(imageBytes.length));
    return newResponseBuilder.create();
  }

  private boolean isUsableParameter(Integer parameterValue) {
    if (parameterValue == null) {
      return true;
View Full Code Here

    httpResponse.addHeader("header", "hval");
    httpResponse.setEncoding(Charset.forName("UTF8"));
    httpResponse.setHttpStatusCode(404);

    GadgetsHandlerApi.ProxyResponse response = gadgetHandler.createProxyResponse(RESOURCE,
            httpResponse.create(), ImmutableSet.<String> of("*"), 1000001L);
    BeanDelegator.validateDelegator(response);
    assertEquals("Content",
            new String(Base64.decodeBase64(response.getProxyContent().getContentBase64())));
    assertEquals(404, response.getProxyContent().getCode());
    assertEquals(2, response.getProxyContent().getHeaders().size());
View Full Code Here

    Capture<List<ProxyUri>> uriCapture = new Capture<List<ProxyUri>>();
    expect(proxyUriManager.make(capture(uriCapture), EasyMock.anyInt())).andReturn(
            ImmutableList.of(resUri));
    HttpResponseBuilder builder = new HttpResponseBuilder();
    builder.setExpirationTime(20000).setContent("response");
    HttpResponse httpResponse = builder.create();
    expect(proxyHandler.fetch(EasyMock.isA(ProxyUri.class))).andReturn(httpResponse);
    replay();
    GadgetsHandlerApi.ProxyResponse response = gadgetHandler.getProxy(request);
    assertEquals(1, uriCapture.getValue().size());
    ProxyUri pUri = uriCapture.getValue().get(0);
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.