• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HttpResponseStatus类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onStatusReceived

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public AsyncHandler.State onStatusReceived(final HttpResponseStatus status) throws Exception {
    responseBuilder.accumulate(status);
    if (status.getStatusCode() == 200 || status.getStatusCode() == 206) {
        url = status.getUri().toUrl();
    } else {
        return AsyncHandler.State.ABORT;
    }

    if (decoratedAsyncHandler != null) {
        return decoratedAsyncHandler.onStatusReceived(status);
    }

    return AsyncHandler.State.CONTINUE;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:19,代码来源:ResumableAsyncHandler.java


示例2: testOnStatusReceivedOkStatusWithDecoratedAsyncHandler

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@Test
public void testOnStatusReceivedOkStatusWithDecoratedAsyncHandler() throws Exception {
    HttpResponseStatus mockResponseStatus = mock(HttpResponseStatus.class);
    when(mockResponseStatus.getStatusCode()).thenReturn(200);
    when(mockResponseStatus.getUri()).thenReturn(mock(Uri.class));

    @SuppressWarnings("unchecked")
    AsyncHandler<Response> decoratedAsyncHandler = mock(AsyncHandler.class);
    State mockState = mock(State.class);
    when(decoratedAsyncHandler.onStatusReceived(mockResponseStatus)).thenReturn(mockState);

    ResumableAsyncHandler handler = new ResumableAsyncHandler(decoratedAsyncHandler);

    State state = handler.onStatusReceived(mockResponseStatus);
    verify(decoratedAsyncHandler).onStatusReceived(mockResponseStatus);
    assertEquals(state, mockState, "State returned should be equal to the one returned from decoratedAsyncHandler");
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:18,代码来源:ResumableAsyncHandlerTest.java


示例3: testOnBodyPartReceivedWithDecoratedAsyncHandler

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@Test
public void testOnBodyPartReceivedWithDecoratedAsyncHandler() throws Exception {
    HttpResponseBodyPart bodyPart = PowerMockito.mock(HttpResponseBodyPart.class);
    when(bodyPart.getBodyPartBytes()).thenReturn(new byte[0]);
    ByteBuffer buffer = ByteBuffer.allocate(0);
    when(bodyPart.getBodyByteBuffer()).thenReturn(buffer);

    @SuppressWarnings("unchecked")
    AsyncHandler<Response> decoratedAsyncHandler = mock(AsyncHandler.class);
    State mockState = mock(State.class);
    when(decoratedAsyncHandler.onBodyPartReceived(bodyPart)).thenReturn(mockState);

    // following is needed to set the url variable
    HttpResponseStatus mockResponseStatus = mock(HttpResponseStatus.class);
    when(mockResponseStatus.getStatusCode()).thenReturn(200);
    Uri mockUri = mock(Uri.class);
    when(mockUri.toUrl()).thenReturn("http://non.null");
    when(mockResponseStatus.getUri()).thenReturn(mockUri);

    ResumableAsyncHandler handler = new ResumableAsyncHandler(decoratedAsyncHandler);
    handler.onStatusReceived(mockResponseStatus);

    State state = handler.onBodyPartReceived(bodyPart);
    assertEquals(state, mockState, "State should be equal to the state returned from decoratedAsyncHandler");

}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:27,代码来源:ResumableAsyncHandlerTest.java


示例4: UpgradeCallback

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
public UpgradeCallback(NettyResponseFuture<?> future, Channel channel, HttpResponse response, WebSocketUpgradeHandler handler, HttpResponseStatus status,
        HttpResponseHeaders responseHeaders) {
    super(future);
    this.channel = channel;
    this.response = response;
    this.handler = handler;
    this.status = status;
    this.responseHeaders = responseHeaders;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:10,代码来源:WebSocketHandler.java


示例5: exitAfterIntercept

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
public boolean exitAfterIntercept(//
        Channel channel,//
        NettyResponseFuture<?> future,//
        AsyncHandler<?> handler,//
        HttpResponse response,//
        HttpResponseStatus status,//
        HttpResponseHeaders responseHeaders) throws Exception {

    HttpRequest httpRequest = future.getNettyRequest().getHttpRequest();
    ProxyServer proxyServer = future.getProxyServer();
    int statusCode = response.getStatus().code();
    Request request = future.getCurrentRequest();
    Realm realm = request.getRealm() != null ? request.getRealm() : config.getRealm();

    if (hasResponseFilters && responseFiltersInterceptor.exitAfterProcessingFilters(channel, future, handler, status, responseHeaders)) {
        return true;
    }

    if (statusCode == UNAUTHORIZED_401) {
        return unauthorized401Interceptor.exitAfterHandling401(channel, future, response, request, statusCode, realm, proxyServer, httpRequest);

    } else if (statusCode == PROXY_AUTHENTICATION_REQUIRED_407) {
        return proxyUnauthorized407Interceptor.exitAfterHandling407(channel, future, response, request, statusCode, proxyServer, httpRequest);

    } else if (statusCode == CONTINUE_100) {
        return continue100Interceptor.exitAfterHandling100(channel, future, statusCode);

    } else if (Redirect30xInterceptor.REDIRECT_STATUSES.contains(statusCode)) {
        return redirect30xInterceptor.exitAfterHandlingRedirect(channel, future, response, request, statusCode, realm);

    } else if (httpRequest.getMethod() == HttpMethod.CONNECT && statusCode == OK_200) {
        return connectSuccessInterceptor.exitAfterHandlingConnect(channel, future, request, proxyServer, statusCode, httpRequest);

    }
    return false;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:37,代码来源:Interceptors.java


示例6: exitAfterProcessingFilters

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public boolean exitAfterProcessingFilters(//
        Channel channel,//
        NettyResponseFuture<?> future,//
        AsyncHandler<?> handler, //
        HttpResponseStatus status,//
        HttpResponseHeaders responseHeaders) {

    FilterContext fc = new FilterContext.FilterContextBuilder().asyncHandler(handler).request(future.getCurrentRequest()).responseStatus(status)
            .responseHeaders(responseHeaders).build();

    for (ResponseFilter asyncFilter : config.getResponseFilters()) {
        try {
            fc = asyncFilter.filter(fc);
            // FIXME Is it worth protecting against this?
            assertNotNull("fc", "filterContext");
        } catch (FilterException efe) {
            requestSender.abort(channel, future, efe);
        }
    }

    // The handler may have been wrapped.
    future.setAsyncHandler(fc.getAsyncHandler());

    // The request has changed
    if (fc.replayRequest()) {
        requestSender.replayRequest(future, fc, channel);
        return true;
    }
    return false;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:32,代码来源:ResponseFiltersInterceptor.java


示例7: NettyResponse

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
public NettyResponse(HttpResponseStatus status,//
        HttpResponseHeaders headers,//
        List<HttpResponseBodyPart> bodyParts) {
    this.bodyParts = bodyParts;
    this.headers = headers;
    this.status = status;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:8,代码来源:NettyResponse.java


示例8: zeroCopyFileTest

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@Test(groups = "standalone")
public void zeroCopyFileTest() throws IOException, ExecutionException, TimeoutException, InterruptedException, URISyntaxException {
    File tmp = new File(System.getProperty("java.io.tmpdir") + File.separator + "zeroCopy.txt");
    tmp.deleteOnExit();
    try (AsyncHttpClient client = asyncHttpClient()) {
        try (FileOutputStream stream = new FileOutputStream(tmp)) {
            Response resp = client.preparePost("http://localhost:" + port1 + "/").setBody(SIMPLE_TEXT_FILE).execute(new AsyncHandler<Response>() {
                public void onThrowable(Throwable t) {
                }

                public State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception {
                    stream.write(bodyPart.getBodyPartBytes());
                    return State.CONTINUE;
                }

                public State onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
                    return State.CONTINUE;
                }

                public State onHeadersReceived(HttpResponseHeaders headers) throws Exception {
                    return State.CONTINUE;
                }

                public Response onCompleted() throws Exception {
                    return null;
                }
            }).get();
            assertNull(resp);
            assertEquals(SIMPLE_TEXT_FILE.length(), tmp.length());
        }
    }
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:33,代码来源:ZeroCopyFileTest.java


示例9: zeroCopyFileWithBodyManipulationTest

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@Test(groups = "standalone")
public void zeroCopyFileWithBodyManipulationTest() throws IOException, ExecutionException, TimeoutException, InterruptedException, URISyntaxException {
    File tmp = new File(System.getProperty("java.io.tmpdir") + File.separator + "zeroCopy.txt");
    tmp.deleteOnExit();
    try (AsyncHttpClient client = asyncHttpClient()) {
        try (FileOutputStream stream = new FileOutputStream(tmp)) {
            Response resp = client.preparePost("http://localhost:" + port1 + "/").setBody(SIMPLE_TEXT_FILE).execute(new AsyncHandler<Response>() {
                public void onThrowable(Throwable t) {
                }

                public State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception {
                    stream.write(bodyPart.getBodyPartBytes());

                    if (bodyPart.getBodyPartBytes().length == 0) {
                        return State.ABORT;
                    }

                    return State.CONTINUE;
                }

                public State onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
                    return State.CONTINUE;
                }

                public State onHeadersReceived(HttpResponseHeaders headers) throws Exception {
                    return State.CONTINUE;
                }

                public Response onCompleted() throws Exception {
                    return null;
                }
            }).get();
            assertNull(resp);
            assertEquals(SIMPLE_TEXT_FILE.length(), tmp.length());
        }
    }
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:38,代码来源:ZeroCopyFileTest.java


示例10: testOnStatusReceivedOkStatus

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@Test
public void testOnStatusReceivedOkStatus() throws Exception {
    MapResumableProcessor processor = new MapResumableProcessor();
    ResumableAsyncHandler handler = new ResumableAsyncHandler(processor);
    HttpResponseStatus responseStatus200 = mock(HttpResponseStatus.class);
    when(responseStatus200.getStatusCode()).thenReturn(200);
    when(responseStatus200.getUri()).thenReturn(mock(Uri.class));
    State state = handler.onStatusReceived(responseStatus200);
    assertEquals(state, AsyncHandler.State.CONTINUE, "Status should be CONTINUE for a OK response");
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:11,代码来源:ResumableAsyncHandlerTest.java


示例11: testOnStatusReceived206Status

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@Test
public void testOnStatusReceived206Status() throws Exception {
    MapResumableProcessor processor = new MapResumableProcessor();
    ResumableAsyncHandler handler = new ResumableAsyncHandler(processor);
    HttpResponseStatus responseStatus206 = mock(HttpResponseStatus.class);
    when(responseStatus206.getStatusCode()).thenReturn(206);
    when(responseStatus206.getUri()).thenReturn(mock(Uri.class));
    State state = handler.onStatusReceived(responseStatus206);
    assertEquals(state, AsyncHandler.State.CONTINUE, "Status should be CONTINUE for a 'Partial Content' response");
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:11,代码来源:ResumableAsyncHandlerTest.java


示例12: testOnStatusReceived500Status

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@Test
public void testOnStatusReceived500Status() throws Exception{
    MapResumableProcessor processor = new MapResumableProcessor();
    ResumableAsyncHandler handler = new ResumableAsyncHandler(processor);
    HttpResponseStatus mockResponseStatus = mock(HttpResponseStatus.class);
    when(mockResponseStatus.getStatusCode()).thenReturn(500);
    when(mockResponseStatus.getUri()).thenReturn(mock(Uri.class));
    State state = handler.onStatusReceived(mockResponseStatus);
    assertEquals(state, AsyncHandler.State.ABORT, "State should be ABORT for Internal Server Error status");
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:11,代码来源:ResumableAsyncHandlerTest.java


示例13: transactionMarker

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@Override
public void transactionMarker() throws Exception {
    AsyncHttpClient asyncHttpClient = new DefaultAsyncHttpClient();
    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


示例14: onStatusReceived

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@Override
public State onStatusReceived(HttpResponseStatus status) throws Exception {
    monitorService.sendStatus(String.valueOf(status.getStatusCode()), start);
    return State.CONTINUE;
}
 
开发者ID:globocom,项目名称:groot,代码行数:6,代码来源:RequestExecutorService.java


示例15: onStatusReceived

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
@Override
public State onStatusReceived(HttpResponseStatus responseStatus)
        throws Exception {
    statusCode = responseStatus.getStatusCode();
    return asyncHandler.onStatusReceived(responseStatus);
}
 
开发者ID:yahoo,项目名称:metrics-api,代码行数:7,代码来源:ToyClientMetricsEmitter.java


示例16: onStatusReceived

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public final State onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
    status = responseStatus.getStatusCode();
    return status == SWITCHING_PROTOCOLS ? State.UPGRADE : State.ABORT;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:9,代码来源:WebSocketUpgradeHandler.java


示例17: onStatusReceived

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
public State onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
    responseBuilder.reset();
    responseBuilder.accumulate(responseStatus);
    return State.CONTINUE;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:6,代码来源:BodyDeferringAsyncHandler.java


示例18: onStatusReceived

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public final State onStatusReceived(final HttpResponseStatus status) throws Exception {
    this.status = status;
    return State.CONTINUE;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:9,代码来源:WebDavCompletionHandlerBase.java


示例19: HttpStatusWrapper

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
public HttpStatusWrapper(HttpResponseStatus wrapper, String statusText, int statusCode) {
    super(wrapper.getUri(), null);
    this.wrapped = wrapper;
    this.statusText = statusText;
    this.statusCode = statusCode;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:7,代码来源:WebDavCompletionHandlerBase.java


示例20: onStatusReceived

import org.asynchttpclient.HttpResponseStatus; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public State onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
    return asyncHandler.onStatusReceived(responseStatus);
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:8,代码来源:AsyncHandlerWrapper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Cigar类代码示例发布时间:2022-05-22
下一篇:
Java MeasurementScheduleRequest类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap