当前位置: 首页>>代码示例>>Java>>正文


Java HttpResponseStatus类代码示例

本文整理汇总了Java中com.ning.http.client.HttpResponseStatus的典型用法代码示例。如果您正苦于以下问题:Java HttpResponseStatus类的具体用法?Java HttpResponseStatus怎么用?Java HttpResponseStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpResponseStatus类属于com.ning.http.client包,在下文中一共展示了HttpResponseStatus类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onStatusReceived

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
public com.ning.http.client.AsyncHandler.STATE onStatusReceived(
		HttpResponseStatus responseStatus) throws Exception {
	
	int statusCode = responseStatus.getStatusCode();
	testCaseReport.setResponseStatusCode(statusCode);
	if (statusCode != testCase.getExpectedResCode()) {
		testCaseReport.setError("Expected status code ["+testCase.getExpectedResCode()
				+"] does not match actual status code ["+statusCode+"]");
		testCaseReport.setStatus(TestStatus.Failed.status);
		testCaseReport.setFailureReason(TestFailureReason.InvalidStatusCode.status);
		if(testCase.isAbortOnInvalidStatusCode())
           {
			return STATE.ABORT;
           }
       }
	builder.accumulate(responseStatus);
	return STATE.CONTINUE;
}
 
开发者ID:sumeetchhetri,项目名称:gatf,代码行数:19,代码来源:TestCaseExecutorUtil.java

示例2: onStatusReceived

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
@Override
public STATE onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
    if (log.isTraceEnabled()) {
        log.trace("{} onStatusReceived {}", exchange.getExchangeId(), responseStatus);
    }
    try {
        statusCode = responseStatus.getStatusCode();
        statusText = responseStatus.getStatusText();
        getEndpoint().getBinding().onStatusReceived(getEndpoint(), exchange, responseStatus);
    } catch (Exception e) {
        exchange.setException(e);
    }
    return STATE.CONTINUE;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:AhcProducer.java

示例3: onStatusReceived

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
@Override
public void onStatusReceived(AhcEndpoint endpoint, Exchange exchange, HttpResponseStatus responseStatus) throws Exception {
    // preserve headers from in by copying any non existing headers
    // to avoid overriding existing headers with old values
    // Just filter the http protocol headers 
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), httpProtocolHeaderFilterStrategy, false);
    exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, responseStatus.getStatusCode());
    exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_TEXT, responseStatus.getStatusText());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:DefaultAhcBinding.java

示例4: transactionMarker

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
@Override
public void transactionMarker() throws Exception {
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicInteger statusCode = new AtomicInteger();
    asyncHttpClient.prepareGet("http://localhost:" + getPort() + "/hello3/")
            .execute(new AsyncHandler<Response>() {
                @Override
                public STATE onBodyPartReceived(HttpResponseBodyPart part) {
                    return null;
                }
                @Override
                public Response onCompleted() throws Exception {
                    latch.countDown();
                    return null;
                }
                @Override
                public STATE onHeadersReceived(HttpResponseHeaders headers) {
                    return null;
                }
                @Override
                public STATE onStatusReceived(HttpResponseStatus status) {
                    statusCode.set(status.getStatusCode());
                    return null;
                }
                @Override
                public void onThrowable(Throwable t) {}
            });
    latch.await();
    asyncHttpClient.close();
    if (statusCode.get() != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:35,代码来源:AsyncHttpClientPluginIT.java

示例5: prepareResponse

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
public Response prepareResponse(HttpResponseStatus status, HttpResponseHeaders headers, List<HttpResponseBodyPart> bodyParts) {
    return new JDKResponse(status, headers, bodyParts);
}
 
开发者ID:yongbeam,项目名称:Android-kakaologin-gradle-sample,代码行数:4,代码来源:SimpleAsyncHttpProvider.java

示例6: onStatusReceived

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
@Override
public STATE onStatusReceived(final HttpResponseStatus responseStatus) throws Exception {

  this.status = responseStatus;
  return STATE.CONTINUE;
}
 
开发者ID:outbrain,项目名称:ob1k,代码行数:7,代码来源:NingHttpTypedStreamHandler.java

示例7: HTTPAsyncPost

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
public HTTPAsyncPost(AsyncHttpClient client, HTTPLogObject http_log) {

		RequestBuilder builder = new RequestBuilder("POST");
		url_request = http_log.getURLRequest();

		HTTPUtils util = new HTTPUtils();
		builder = util.buildDefaultHeaders(builder, http_log);
		
		// Add additional POST headers, if specified
		builder = util.buildCustomPOSTHeaders(builder, http_log);
		
		builder.addHeader("User-Agent", http_log.getUseragent());
		
		String one_time_payload = POSTPayloadCache.instance.fetchPayload(http_log.getRequest());
		logger.debug("Here is the randomized payload: " + one_time_payload);
		builder.setBody(one_time_payload);

		Request request = builder.setUrl(http_log.getURLRequest()).build();

		AsyncHandler<Response> asyncHandler = new AsyncHandler<Response>() {
			private final Response.ResponseBuilder builder = new Response.ResponseBuilder();

			public STATE onBodyPartReceived(final HttpResponseBodyPart content)
					throws Exception {
				builder.accumulate(content);
				return STATE.CONTINUE;
			}

			public STATE onStatusReceived(final HttpResponseStatus status)
					throws Exception {
				builder.accumulate(status);
				return STATE.CONTINUE;
			}

			public STATE onHeadersReceived(final HttpResponseHeaders headers)
					throws Exception {
				builder.accumulate(headers);
				return STATE.CONTINUE;	
			}

			public Response onCompleted() throws Exception {
				logger.debug("POST - " + url_request + " - "
						+ builder.build().getStatusCode());
				return builder.build();
			}

			@Override
			public void onThrowable(Throwable t) {
				logger.error(t.getMessage());
			}
		};

		try {
			client.executeRequest(request, asyncHandler);
		} catch (IOException e) {
			logger.error(e.getMessage());
		}
	}
 
开发者ID:broamski,项目名称:cantilever,代码行数:59,代码来源:HTTPAsyncPost.java

示例8: HTTPAsyncGet

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
public HTTPAsyncGet(AsyncHttpClient client, HTTPLogObject http_log) {

		RequestBuilder builder = new RequestBuilder("GET");
		url_request = http_log.getURLRequest();
		
		HTTPUtils util = new HTTPUtils();
		builder = util.buildDefaultHeaders(builder, http_log);

		// Add additional GET headers, if specified
		builder = util.buildCustomGETHeaders(builder, http_log);
		
		builder.addHeader("User-Agent", http_log.getUseragent());
		
		Request request = builder.setUrl(url_request).build();

		AsyncHandler<Response> asyncHandler = new AsyncHandler<Response>() {
			private final Response.ResponseBuilder builder = new Response.ResponseBuilder();

			public STATE onBodyPartReceived(final HttpResponseBodyPart content)
					throws Exception {
				builder.accumulate(content);
				return STATE.CONTINUE;
			}

			public STATE onStatusReceived(final HttpResponseStatus status)
					throws Exception {
				builder.accumulate(status);
				return STATE.CONTINUE;
			}

			public STATE onHeadersReceived(final HttpResponseHeaders headers)
					throws Exception {
				builder.accumulate(headers);
				return STATE.CONTINUE;
			}

			public Response onCompleted() throws Exception {
				logger.debug("GET - " + url_request + " - "
						+ builder.build().getStatusCode());
				return builder.build();
			}

			@Override
			public void onThrowable(Throwable t) {
				logger.error(t.getMessage());
			}
		};

		try {
			client.executeRequest(request, asyncHandler);
		} catch (IOException e) {
			logger.error(e.getMessage());
		}
	}
 
开发者ID:broamski,项目名称:cantilever,代码行数:55,代码来源:HTTPAsyncGet.java

示例9: sse

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
public String sse(final String path, final int count) throws Exception {
  CountDownLatch latch = new CountDownLatch(count);
  String result = client.prepareGet("http://localhost:" + port + path)
      .addHeader("Content-Type", MediaType.sse.name())
      .addHeader("last-event-id", count + "")
      .execute(new AsyncHandler<String>() {

        StringBuilder sb = new StringBuilder();

        @Override
        public void onThrowable(final Throwable t) {
          t.printStackTrace();
        }

        @Override
        public AsyncHandler.STATE onBodyPartReceived(final HttpResponseBodyPart bodyPart)
            throws Exception {
          sb.append(new String(bodyPart.getBodyPartBytes(), StandardCharsets.UTF_8));
          latch.countDown();
          return AsyncHandler.STATE.CONTINUE;
        }

        @Override
        public AsyncHandler.STATE onStatusReceived(final HttpResponseStatus responseStatus)
            throws Exception {
          assertEquals(200, responseStatus.getStatusCode());
          return AsyncHandler.STATE.CONTINUE;
        }

        @Override
        public AsyncHandler.STATE onHeadersReceived(final HttpResponseHeaders headers)
            throws Exception {
          FluentCaseInsensitiveStringsMap h = headers.getHeaders();
          assertEquals("close", h.get("Connection").get(0).toLowerCase());
          assertEquals("text/event-stream; charset=utf-8",
              h.get("Content-Type").get(0).toLowerCase());
          return AsyncHandler.STATE.CONTINUE;
        }

        @Override
        public String onCompleted() throws Exception {
          return sb.toString();
        }
      }).get();

  latch.await();
  return result;
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:49,代码来源:SseFeature.java

示例10: onStatusReceived

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
@Override
public STATE onStatusReceived(HttpResponseStatus status) throws Exception {
    builder.reset();
    builder.accumulate(status);
    return STATE.CONTINUE;
}
 
开发者ID:AlgeFramework,项目名称:alge-core,代码行数:7,代码来源:GenericAsyncHandler.java

示例11: testEntityChunkedOutput

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
@Test
public void testEntityChunkedOutput() throws URISyntaxException, IOException, ExecutionException, InterruptedException {

    Inflector<ContainerRequestContext, ChunkedOutput<?>> inflector = new Inflector<ContainerRequestContext, ChunkedOutput<?>>() {

        @Override
        public ChunkedOutput<Entity> apply(ContainerRequestContext containerRequestContext) {
            final ChunkedOutput<Entity> output = new ChunkedOutput<Entity>(Entity.class);
            new Thread() {
                int i = 0;

                @Override
                public void run() {
                    try {
                        while (i <= 4) {
                            if (i == 0) {
                                output.write(new Entity(true, 0));
                            } else {
                                output.write(new Entity(false, 1000));
                            }
                            i++;
                        }
                        output.close();
                    } catch (IOException e) {
                        fail("writing should not fail", e);
                    }
                }
            }.start();
            return output;
        }
    };
    ServerBootstrap bootstrap = getServerBootstrap();
    int port = bindJerseyServer(inflector, bootstrap, EntityWriter.class);

    final AsyncHttpClient client = getHttpClient();
    ListenableFuture<Object> request = client.prepareGet("http://localhost:" + port + "/").execute(new AsyncHandler<Object>() {
        @Override
        public void onThrowable(Throwable t) {
            fail("Should not throw up", t);
        }

        @Override
        public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception {
            return STATE.CONTINUE;
        }

        @Override
        public STATE onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
            return STATE.CONTINUE;
        }

        @Override
        public STATE onHeadersReceived(HttpResponseHeaders headers) throws Exception {
            return STATE.CONTINUE;
        }

        @Override
        public Object onCompleted() throws Exception {
            return STATE.CONTINUE;
        }
    });
    request.get();
    bootstrap.shutdown();
}
 
开发者ID:graylog-labs,项目名称:jersey-netty,代码行数:65,代码来源:NettyContainerTest.java

示例12: onStatusReceived

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
public AsyncHandler.STATE onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
  responseBuilder.reset();
  responseBuilder.accumulate(responseStatus);
  statusReceived = true;
  return AsyncHandler.STATE.CONTINUE;
}
 
开发者ID:apache,项目名称:tez,代码行数:7,代码来源:TezBodyDeferringAsyncHandler.java

示例13: onStatusReceived

import com.ning.http.client.HttpResponseStatus; //导入依赖的package包/类
/**
 * Callback from the {@link com.ning.http.client.AsyncHttpClient} when the HTTP response status was received
 *
 * @param endpoint       the endpoint
 * @param exchange       the exchange
 * @param responseStatus the HTTP response status
 * @throws Exception is thrown if error occurred in the callback
 */
void onStatusReceived(AhcEndpoint endpoint, Exchange exchange, HttpResponseStatus responseStatus) throws Exception;
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:AhcBinding.java


注:本文中的com.ning.http.client.HttpResponseStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。