Package org.apache.shindig.gadgets.http

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


    final OAuth2Accessor accessor = MockUtils.getOAuth2Accessor_Code();
    final HttpResponseBuilder builder = new HttpResponseBuilder().setStrictNoCache();
    builder.setHttpStatusCode(HttpResponse.SC_OK);
    builder.setHeader("Content-Type", "BAD");
    builder.setContent("access_token=xxx&token_type=Bearer&expires=1&refresh_token=yyy&example_parameter=example_value");
    final HttpResponse response = builder.create();

    final OAuth2HandlerError result = TokenAuthorizationResponseHandlerTest.tarh.handleResponse(
            accessor, response);

    Assert.assertNull(result);
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

      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 {
    OAuthValidator validator = new FakeTimeOAuthValidator();
View Full Code Here

    // Copy the content.
    // TODO: replace this with streaming APIs when ready
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    IOUtils.copy(results.getResponse(), baos);
    response.setResponseNoCopy(baos.toByteArray());
    return response.create();
  }

  /**
   * Returns the proxy uri encapsulating the request uri.
   * @param httpRequest The http request.
View Full Code Here

    // TODO: replace this with streaming APIs when ready
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    IOUtils.copy(results.getResponse(), baos);
    response.setResponse(baos.toByteArray());
    return response.create();
  }

  protected void setResponseContentHeaders(HttpResponseBuilder response, HttpResponse results) {
    // We're skipping the content disposition header for flash due to an issue with Flash player 10
    // This does make some sites a higher value phishing target, but this can be mitigated by
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 {
    OAuthValidator validator = new FakeTimeOAuthValidator();
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 OAuth2Token haveAccessToken(final OAuth2Accessor accessor) {
    OAuth2Token ret = accessor.getAccessToken();
    if (ret != null) {
View Full Code Here

    final OAuth2ResponseParams fixture = new OAuth2ResponseParams();
    fixture.addDebug("");
    fixture.setAuthorizationUrl("");
    final HttpResponseBuilder responseBuilder = new HttpResponseBuilder().setStrictNoCache();
    final HttpRequest request = new HttpRequest(Uri.fromJavaUri(new URI("")));
    final HttpResponse response = responseBuilder.create();

    fixture.addRequestTrace(request, response);
  }

  @Test
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.