Examples of HttpResponse


Examples of com.google.opengse.HttpResponse

    HttpRequestImpl req = new HttpRequestImpl(requestMetaData, inputStream);
    if (req.getMethod().equalsIgnoreCase("HEAD")) {
      ostr = new NoBodyOutputStream(ostr);
    }
    ServletOutputStreamImpl outputStream = new ServletOutputStreamImpl(ostr, 2048);
    HttpResponse resp = null;
    try {
      resp = new HttpResponseImpl(req, outputStream);
      handler.handleRequest(req, resp);
    } finally {
      // ensure that any buffered bytes get committed. No byte left behind!
      resp.flushBuffer();
    }
  }
View Full Code Here

Examples of com.google.wave.api.WaveService.HttpResponse

  private final List<EventType> calledEvents = new ArrayList<EventType>();

  public void testSubmit() throws Exception {
    HttpFetcher fetcher = mock(HttpFetcher.class);
    when(fetcher.execute(any(HttpMessage.class), anyMapOf(String.class, Object.class)))
        .thenReturn(new HttpResponse("POST", new URL("http://foo.google.com"), 0,
            new ByteArrayInputStream("[{\"id\":\"op1\",\"data\":{}}]".getBytes())));


    MockRobot robot = new MockRobot();
    robot.setupOAuth("consumerKey", "consumerSecret", "http://gmodules.com/api/rpc");
View Full Code Here

Examples of com.googlecode.batchfb.util.RequestBuilder.HttpResponse

    RequestBuilder request = new RequestBuilder(VERIFY_LINK, HttpMethod.POST);
    request.addParam("assertion", assertion);
    request.addParam("audience", audience);

    HttpResponse response = request.execute();
    if (response.getResponseCode() != HttpServletResponse.SC_OK)
      throw new IllegalStateException("Bad response code: " + response.getResponseCode());

    Assertion result = MAPPER.readValue(response.getContentStream(), Assertion.class);

    if (!"okay".equals(result.getStatus()))
      throw new IllegalStateException("Bad assertion content: " + result);

    if (result.getExpires() < System.currentTimeMillis())
View Full Code Here

Examples of com.hubspot.horizon.HttpResponse

    }

  }

  private HttpResponse getFromMesos(String uri) {
    HttpResponse response = null;

    final long start = System.currentTimeMillis();

    LOG.debug("Fetching {} from mesos", uri);

    try {
      response = httpClient.execute(HttpRequest.newBuilder().setUrl(uri).build());

      LOG.debug("Response {} - {} after {}", response.getStatusCode(), uri, JavaUtils.duration(start));
    } catch (Exception e) {
      throw new MesosClientException(String.format("Exception fetching %s after %s", uri, JavaUtils.duration(start)), e);
    }

    if (!response.isSuccess()) {
      throw new MesosClientException(String.format("Invalid response code from %s : %s", uri, response.getStatusCode()));
    }

    return response;
  }
View Full Code Here

Examples of com.lgx8.common.payment.util.httpClient.HttpResponse

        request.setCharset(AlipayMerchantConfig.input_charset);

        request.setParameters(generatNameValuePair(sPara));
        request.setUrl(gateway+"_input_charset="+AlipayMerchantConfig.input_charset);

        HttpResponse response = httpProtocolHandler.execute(request);
        if (response == null) {
            return null;
        }
       
        String strResult = response.getStringResult();

        return strResult;
    }
View Full Code Here

Examples of com.maverick.http.HttpResponse

  private void connectAgent() throws IOException, HttpException,
      UnsupportedAuthenticationException,
      AuthenticationCancelledException {

    HttpResponse response = null;
    HttpAuthenticator authenticator = null;
    String ticketToSend = ticket;
   
    boolean doPreemptive = ticketIsPassword;

    try {
           
      for (int i = 0; i < 3; i++) {

              HttpClient client = getHttpClient();
              if (doPreemptive) {
                  client.setCredentials(new PasswordCredentials(username,
                          ticket));
                  client.setPreferredAuthentication("Basic");
              }
              else {
                  client.setCredentials(null);
              }

        // #ifdef DEBUG
        log.info("Registering with the server"); //$NON-NLS-1$
        log.info("Server is " + (isSecure ? "https://" : "http://") + getAditoHost() //$NON-NLS-1$
            + ":" + getAditoPort()); //$NON-NLS-1$
        // #endif
        GetMethod post = new GetMethod("/agent"); //$NON-NLS-1$

              client.setPreemtiveAuthentication(doPreemptive);
        if (!doPreemptive && ticket != null) {
          post.setParameter("ticket", ticket); //$NON-NLS-1$
        }

        post.setParameter(
            "agentType", getConfiguration().getAgentType()); //$NON-NLS-1$ //$NON-NLS-2$
        post.setParameter("locale", Locale.getDefault().toString()); //$NON-NLS-1$

        response = client.execute(post);

        if (response.getStatus() == 302) {
          // Reset the client
          this.client = null;

          URL url = new URL(response.getHeaderField("Location")); //$NON-NLS-1$
          aditoHostname = url.getHost();
          if (url.getPort() > 0)
            aditoPort = url.getPort();
          continue;
        } else if (response.getStatus() == 200) {
          con.addListener(this);
          httpConnection = response.getConnection(); // Preserve the
          // connection
          con.registerRequestHandler(MESSAGE_REQUEST, this);
          con.registerRequestHandler(SHUTDOWN_REQUEST, this);
          con.registerRequestHandler(OPEN_URL_REQUEST, this);
          con.registerRequestHandler(UPDATE_RESOURCES_REQUEST, this);

          // Start the protocol

          con.startProtocol(
              response.getConnection().getInputStream(), response
                  .getConnection().getOutputStream(), true);

          // Synchronize and read back server information
          Request syncRequest = new Request(SYNCHRONIZED_REQUEST);
          con.sendRequest(syncRequest, true);
          if (syncRequest.getRequestData() == null)
            throw new IOException(
                "Server failed to return version data");

          ByteArrayReader reader = new ByteArrayReader(syncRequest
              .getRequestData());
          serverVersion = reader.readString();

          /**
           * Initialize the managers. Tunnels are no longer recorded
           * here unless they are active. This simplifies the agent by
           * making it respond to start and stop requests from the new
           * persistent connection with Adito.
           */
          tunnelManager = new TunnelManager(this);
          applicationManager = new ApplicationManager(this);
          webForwardManager = new WebForwardManager(this);
          networkPlaceManager = new NetworkPlaceManager(this);
          updateResources(-1);
          return;
        } else if (response.getStatus() == 401) {
          authenticator = HttpAuthenticatorFactory
              .createAuthenticator(
                  response.getConnection(),
                  response
                      .getHeaderFields("WWW-Authenticate"),
                  "WWW-Authenticate", "Authorization",
                  HttpAuthenticatorFactory.BASIC, post
                      .getURI());
          if (authenticator.wantsPrompt()) {
            if ( !( defaultAuthenticationPrompt != null ? defaultAuthenticationPrompt.promptForCredentials(false, authenticator) :
                getGUI().promptForCredentials(false, authenticator) ) ) {
              throw new AuthenticationCancelledException();
            }
          }
        } else if(response.getStatus() == 403) {
            if(doPreemptive || ticket != null) {
                doPreemptive = false;
                ticket = null;
            }
            else {
              throw new IOException(MessageFormat.format(Messages
                  .getString("VPNClient.register.failed"),
                  new Object[] {
                      String.valueOf(response.getStatus()),
                      response.getReason() }));
            }
        }
      }

      throw new IOException(Messages
View Full Code Here

Examples of com.netflix.client.http.HttpResponse

            }
        }

        HttpRequest httpClientRequest = builder.build();

        HttpResponse response = restClient.executeWithLoadBalancer(httpClientRequest);
        context.set("ribbonResponse", response);
        return response;
    }
View Full Code Here

Examples of com.nimbusds.oauth2.sdk.http.HTTPResponse

    URI uri = resp.toURI();

    System.out.println("Location: " + uri);

    HTTPResponse httpResponse = resp.toHTTPResponse();
    assertEquals(302, httpResponse.getStatusCode());
    assertEquals(uri, httpResponse.getLocation());

    resp = AuthorizationSuccessResponse.parse(httpResponse);

    assertEquals(ABS_REDIRECT_URI, resp.getRedirectionURI());
    assertEquals(TOKEN, resp.getAccessToken());
View Full Code Here

Examples of com.noelios.restlet.http.HttpResponse

            // Convert the Servlet call to a Restlet call
            final ServletCall servletCall = new ServletCall(request
                    .getLocalAddr(), request.getLocalPort(), request, response);
            final HttpRequest httpRequest = toRequest(servletCall);
            final HttpResponse httpResponse = new HttpResponse(servletCall,
                    httpRequest);

            // Adjust the relative reference
            httpRequest.getResourceRef().setBaseRef(getBaseRef(request));
View Full Code Here

Examples of com.scooterframework.common.http.HTTPResponse

   * Test <tt>index()</tt> method.
   */
  @Test
  public void test_index() {
    String uri = "/entries";
    HTTPResponse response = fireHttpGetRequest(uri);
    assertSuccess(response);
  }
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.