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

Java HttpChannel类代码示例

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

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



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

示例1: beforeMethod

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    MethodInterceptResult result) throws Throwable {
    HttpChannel httpChannel = (HttpChannel)allArguments[0];
    HttpServletRequest servletRequest = httpChannel.getRequest();

    ContextCarrier contextCarrier = new ContextCarrier();

    CarrierItem next = contextCarrier.items();
    while (next.hasNext()) {
        next = next.next();
        next.setHeadValue(servletRequest.getHeader(next.getHeadKey()));
    }

    AbstractSpan span = ContextManager.createEntrySpan(servletRequest.getRequestURI(), contextCarrier);
    Tags.URL.set(span, servletRequest.getRequestURL().toString());
    Tags.HTTP.METHOD.set(span, servletRequest.getMethod());
    span.setComponent(ComponentsDefine.JETTY_SERVER);
    SpanLayer.asHttp(span);
}
 
开发者ID:apache,项目名称:incubator-skywalking,代码行数:21,代码来源:HandleInterceptor.java


示例2: shouldSetSecureSiteURLWhenSiteUrlIsConfigured

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
@Test
public void shouldSetSecureSiteURLWhenSiteUrlIsConfigured() throws URISyntaxException {
    final ServerConfigService serverConfigService = mock(ServerConfigService.class);
    when(serverConfigService.hasAnyUrlConfigured()).thenReturn(true);
    when(serverConfigService.siteUrlFor("http://url/go/admin?tab=oAuth", true)).thenReturn("https://url/go/admin?tab=oAuth");

    Request request = new Request(mock(HttpChannel.class), mock(HttpInput.class));
    request.setUri(new HttpURI("/go/admin?tab=oAuth"));
    request.setServerName("url");

    DeploymentContextWriter writer = new DeploymentContextWriter() {
        @Override protected BaseUrlProvider getBaseUrlProvider(HttpServletRequest req) {
            return serverConfigService;
        }
    };
    writer.writeSecureSiteUrl(request);
    assertThat(request.getAttribute("secure_site"), is("https://url/go/admin?tab=oAuth"));
    assertThat(request.getAttribute("force_ssl"), is("true"));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:DeploymentContextWriterTest.java


示例3: serve

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
@Override
public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) throws Exception {
    final ArmeriaConnector connector = this.connector;

    final HttpResponseWriter res = HttpResponse.streaming();

    req.aggregate().handle(voidFunction((aReq, cause) -> {
        if (cause != null) {
            logger.warn("{} Failed to aggregate a request:", ctx, cause);
            res.close(HttpHeaders.of(HttpStatus.INTERNAL_SERVER_ERROR));
            return;
        }

        boolean success = false;
        try {
            final ArmeriaHttpTransport transport = new ArmeriaHttpTransport(req.method());
            final HttpChannel httpChannel = new HttpChannel(
                    connector,
                    connector.getHttpConfiguration(),
                    new ArmeriaEndPoint(hostname, connector.getScheduler(),
                                        ctx.localAddress(), ctx.remoteAddress()),
                    transport);

            fillRequest(ctx, aReq, httpChannel.getRequest());

            ctx.blockingTaskExecutor().execute(() -> invoke(ctx, res, transport, httpChannel));
            success = true;
        } finally {
            if (!success) {
                res.close();
            }
        }
    })).exceptionally(CompletionActions::log);

    return res;
}
 
开发者ID:line,项目名称:armeria,代码行数:37,代码来源:JettyService.java


示例4: invoke

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
private void invoke(ServiceRequestContext ctx, HttpResponseWriter res,
                    ArmeriaHttpTransport transport, HttpChannel httpChannel) {

    final Queue<HttpData> out = transport.out;
    try {
        server.handle(httpChannel);
        httpChannel.getResponse().getHttpOutput().flush();

        final Throwable cause = transport.cause;
        if (cause != null) {
            throw cause;
        }

        final HttpHeaders headers = toResponseHeaders(transport);
        res.write(headers);
        for (;;) {
            final HttpData data = out.poll();
            if (data == null || !res.write(data)) {
                break;
            }
        }
        res.close();
    } catch (Throwable t) {
        logger.warn("{} Failed to produce a response:", ctx, t);
        res.close();
    }
}
 
开发者ID:line,项目名称:armeria,代码行数:28,代码来源:JettyService.java


示例5: afterMethod

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
    Object ret) throws Throwable {
    HttpChannel httpChannel = (HttpChannel)allArguments[0];
    HttpServletResponse servletResponse = httpChannel.getResponse();
    AbstractSpan span = ContextManager.activeSpan();
    if (servletResponse.getStatus() >= 400) {
        span.errorOccurred();
        Tags.STATUS_CODE.set(span, Integer.toString(servletResponse.getStatus()));
    }
    ContextManager.stopSpan();
    return ret;
}
 
开发者ID:apache,项目名称:incubator-skywalking,代码行数:14,代码来源:HandleInterceptor.java


示例6: getRequest

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
@Override
protected Request getRequest(final Object[] args) {
    if (args == null || args.length < 1) {
        return null;
    }

    if (args[0] instanceof HttpChannel) {
        final HttpChannel<?> channel = (HttpChannel<?>) args[0];
        return channel.getRequest();
    }
    return null;
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:13,代码来源:ServerHandleInterceptor.java


示例7: handshake

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
@Override
protected void handshake(final Runnable handler) throws Exception {
  /** Infinite timeout because the continuation is never resumed but only completed on close. */
  req.getAsyncContext().setTimeout(0L);
  /** Server sent events headers. */
  rsp.setStatus(HttpServletResponse.SC_OK);
  rsp.setHeader("Connection", "Close");
  rsp.setContentType("text/event-stream; charset=utf-8");
  rsp.flushBuffer();

  HttpChannel channel = rsp.getHttpChannel();
  Connector connector = channel.getConnector();
  Executor executor = connector.getExecutor();
  executor.execute(handler);
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:16,代码来源:JettySse.java


示例8: handshake

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
@Test
public void handshake() throws Exception {
  new MockUnit(Request.class, Response.class, HttpOutput.class, Runnable.class,
    AsyncContext.class, HttpChannel.class, Connector.class, Executor.class)
    .expect(httpOutput)
    .expect(unit -> {
      AsyncContext async = unit.get(AsyncContext.class);
      async.setTimeout(0L);

      Request req = unit.get(Request.class);
      expect(req.getAsyncContext()).andReturn(async);
    })
    .expect(unit -> {
      Response rsp = unit.get(Response.class);
      rsp.setStatus(200);
      rsp.setHeader("Connection", "Close");
      rsp.setContentType("text/event-stream; charset=utf-8");
      rsp.flushBuffer();

      HttpChannel channel = unit.get(HttpChannel.class);
      expect(rsp.getHttpChannel()).andReturn(channel);

      Connector connector = unit.get(Connector.class);
      expect(channel.getConnector()).andReturn(connector);

      Executor executor = unit.get(Executor.class);
      expect(connector.getExecutor()).andReturn(executor);

      executor.execute(unit.get(Runnable.class));
    })
    .run(unit -> {
      new JettySse(unit.get(Request.class), unit.get(Response.class))
        .handshake(unit.get(Runnable.class));
    });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:36,代码来源:JettySseTest.java


示例9: handle

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
/**
 * Handler method converting a Jetty HttpChannel into a Restlet Call.
 * 
 * @param channel
 *        The channel to handle.
 */
@Override
public void handle( HttpChannel channel ) throws IOException, ServletException
{
	try
	{
		helper.handle( new JettyServerCall( helper.getHelped(), channel, ensureHostHeader ) );
	}
	catch( Throwable e )
	{
		channel.getEndPoint().close();
		throw new IOException( "Restlet exception", e );
	}
}
 
开发者ID:tliron,项目名称:restlet-jetty9,代码行数:20,代码来源:JettyServerHelper.java


示例10: handleAsync

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
@Override
public void handleAsync( HttpChannel channel ) throws IOException, ServletException
{
	// TODO: should we handle async differently?
	handle( channel );
}
 
开发者ID:tliron,项目名称:restlet-jetty9,代码行数:7,代码来源:JettyServerHelper.java


示例11: JettyServerCall

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param server
 *        The parent server.
 * @param channel
 *        The wrapped Jetty HTTP channel.
 * @param ensureHostHeader
 *        Whether to generate a Host header if not provided by the request
 */
public JettyServerCall( Server server, HttpChannel channel, boolean ensureHostHeader )
{
	super( server );
	this.channel = channel;
	this.ensureHostHeader = ensureHostHeader;
}
 
开发者ID:tliron,项目名称:restlet-jetty9,代码行数:17,代码来源:JettyServerCall.java


示例12: getChannel

import org.eclipse.jetty.server.HttpChannel; //导入依赖的package包/类
/**
 * Returns the wrapped Jetty HTTP channel.
 * 
 * @return The wrapped Jetty HTTP channel.
 */
public HttpChannel getChannel()
{
	return channel;
}
 
开发者ID:tliron,项目名称:restlet-jetty9,代码行数:10,代码来源:JettyServerCall.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java IManaPool类代码示例发布时间:2022-05-22
下一篇:
Java ControlExtension类代码示例发布时间: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